‫۶ سال و ۶ ماه قبل، یکشنبه ۲۰ اسفند ۱۳۹۶، ساعت ۲۲:۵۲
یک autocomplete در یکی از Component‌ها دارم که هر دفعه که کاراکتری تایپ می‌شود و درخواست HTTP  ایجاد می‌گردد loading bar نمایش داده می‌شود راهکار مطلوب شما برای جلوگیری از نمایش loading bar چی میتونه باشه؟
با تغییر کلاس سرویس AppConfigService به شکل زیر :

import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";

@Injectable()
export class AppConfigService {

    private config: IAppConfig;

    constructor(private http: HttpClient) { }

    loadClientConfig(): Promise<any> {
        return this.http.get<IAppConfig>("assets/client-config.json")
            .toPromise()
            .then(config => {
                this.config = config;
                console.log("Config", this.config);
            })
            .catch(err => {
                return Promise.reject(err);
            });
    }

    get configuration(): IAppConfig {
        if (!this.config) {
            throw new Error("Attempted to access configuration property before configuration data was loaded.");
        }
        return this.config;
    }
}

export interface IAppConfig {
    apiEndpoint: string;
    loginPath: string;
    logoutPath: string;
    refreshTokenPath: string;
    accessTokenObjectKey: string;
    refreshTokenObjectKey: string;
    adminRoleName: string;
}

و تغییر ماژول CoreModule به شکل زیر :

import { NgModule, Optional, SkipSelf, APP_INITIALIZER } from "@angular/core";
import { CommonModule } from "@angular/common";
import { RouterModule } from "@angular/router";
import { HTTP_INTERCEPTORS } from "@angular/common/http";

// import RxJs needed operators only once
import "./services/rxjs-operators";

import { HeaderComponent } from "./component/header/header.component";
import { AuthGuard } from "./services/auth.guard";
import { AuthInterceptor } from "./services/auth.interceptor";
import { AuthService } from "./services/auth.service";
import { AppConfigService } from "./services/app-config.service";
import { BrowserStorageService } from "./services/browser-storage.service";


@NgModule({
    imports: [CommonModule, RouterModule],
    exports: [
        // components that are used in app.component.ts will be listed here.
        HeaderComponent
    ],
    declarations: [
        // components that are used in app.component.ts will be listed here.
        HeaderComponent
    ],
    providers: [
        // global singleton services of the whole app will be listed here.
        BrowserStorageService,
        AppConfigService,
        AuthService,
        AuthGuard,
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthInterceptor,
            multi: true
        },
        {
            provide: APP_INITIALIZER,
            useFactory: (config: AppConfigService) => () => config.loadClientConfig(),
            deps: [AppConfigService ],
            multi: true
        }
    ]
})
export class CoreModule {
    constructor( @Optional() @SkipSelf() core: CoreModule) {
        if (core) {
            throw new Error("CoreModule should be imported ONLY in AppModule.");
        }
    }
}
با خطای زیر مواجه شدم لطفا راهنمایی بفرمائید :

Error: Provider parse errors:
Cannot instantiate cyclic dependency! ApplicationRef ("[ERROR ->]"): in NgModule AppModule in ./AppModule@-1:-1 
‫۹ سال و ۴ ماه قبل، جمعه ۲۵ اردیبهشت ۱۳۹۴، ساعت ۱۷:۰۸
این روش خیلی سرعت گزارش ساختن را افزایش میده منم قبلا یادمه از این روش استفاده می‌کردم

StiReport report = new StiReport();
var _context = new DBTestContext();
var model = _context.Books.ToList();
report.RegBusinessObject("Books", model);
report.Dictionary.SynchronizeBusinessObjects();
report.Dictionary.Synchronize();
report.DesignWithWpf();
کافی هست متد RegBusinessObject  را دوبار صدا بزنید. مثل اینجا
‫۱۰ سال و ۴ ماه قبل، پنجشنبه ۲۲ خرداد ۱۳۹۳، ساعت ۱۳:۴۵
public class TestModel
    {
        public byte[] MProperty { get; set; }
    }

 public class TestViewModel
    {
       public byte[] VMProperty { get; set; }
    }

class Program
    {
        static void Main(string[] args)
        {
            Mapper.CreateMap<TestModel,TestViewModel>().ForMember(tv=>tv.VMProperty,m=>m.MapFrom(t=>t.MProperty));
            TestModel tm = new TestModel();
            tm.MProperty = new byte[]  { 1, 2, 3 ,4};

            TestViewModel tvm = Mapper.Map<TestModel, TestViewModel>(tm);
            foreach (var item in tvm.VMProperty)
            {
                Console.WriteLine(item.ToString());
            }
            Console.ReadKey();
        }
    }
در صورتی که MProperty، مقدار داشته باشه مشکلی پیش نمیاد اگر هم null باشه بازم مشکلی پیش نمیاد و VMProperty برابر با null هست.
‫۱۱ سال و ۱ ماه قبل، سه‌شنبه ۲۶ شهریور ۱۳۹۲، ساعت ۱۷:۳۸
ممنون مفید بود.
توی Ninject میتونستیم مشخص کنیم یک پلاگین وابسته به پلاگین دیگه باشه. این کار در MEF به چه شکلی انجام میگیرد؟
‫۱۱ سال و ۶ ماه قبل، دوشنبه ۱۲ فروردین ۱۳۹۲، ساعت ۱۸:۱۱
شما اگر که از Automapper استفاده می‌کنی باید ابتدا یک Map ایجاد کنی و بهتر است که این کار در متد Application_Start  انجام بگیرد.به طور مثال:

protected void Application_Start()
        {
          //مپ کردن مدل به ویومدل
          Mapper.CreateMap<DomainClasses.Product, ProductListVM>();
          //مپ کردن ویومدل به مدل  
          Mapper.CreateMap<ProductCreateVM,DomainClasses.Product>();
        }
حال فرض بگیر دیتایی داری که میخوای انتصاب بدی به ViewModel به این شکل عمل میکنی:
public ActionResult ShowList()
{
var productList = _cotext.Products.ToList();
//انتصاب
 var viewmodel = Mapper.Map<List<domain.Products>, List<ProductListVM>>(productList);
 return View(viewmodel);
}
حال برعکس میخوای ViewModel انتصاب بدی به Model :
[HttpPost]
        public virtual ActionResult Create(ProductCreateVM product)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var model = Mapper.Map<ProductCreateVM, domain.Product>(product);
                    _cotext.Products.Add(model);
                    _cotext.SaveChanges();
                    return RedirectToAction(ShowList);
                }
                return View(product);
            }
            catch
            {
                
            }
        }
امیدوارم به درد بخوره.قبل از هر چیز مطالب مربوط به AutoMapper سایت را مطالعه کن مثل:
اگرم خواستی میتونی دستی این انتصاب‌ها را انجام بدی البته من پیشنهاد نمیکنم.
‫۱۱ سال و ۷ ماه قبل، سه‌شنبه ۲۹ اسفند ۱۳۹۱، ساعت ۲۲:۲۷
دوست عزیز آوردن پراپرتی Tedad در کلاس KalaViewModel اشتباهه و همچنین map کردن Anbar_kala با آن.
کار زیر را میتونی انجام بدی:
public class Anbar_KalaViewModel
    {
        public Anbar Anbar { get; set; }
        public Kala Kala{ get; set; }
        public int Tedad { get; set; }
    }
//Class Configure
Mapper.CreateMap<Anbar_Kala,Anbar_KalaViewModel>();


‫۱۱ سال و ۷ ماه قبل، دوشنبه ۲۸ اسفند ۱۳۹۱، ساعت ۱۴:۵۱
public class Kala
{
        [Key]
        public int Kala_id { get; set; }
 
        [DisplayName("نام کالا")]
        public string Name { get; set; }
 
        [DisplayName("قیمت خرید")]
        public double Fee_Kharid { get; set; }
      
        public virtual Brand Brand { get; set; }
     }
 
  public class Brand
    {
        [Key]
        public int Brand_id { get; set; }
        public string Brand_Name { get; set; }
        public virtual ICollection<Kala> Kalas { get; set; }
    }
 
 public class KalaViewModel
    {
        public int Kala_Id { get; set; }
        public string  Name { get; set; }
        public double Fee_Kharid { get; set; }
        public string Brand_Name { get; set; }
    }
 
     //Controller
     [HttpGet]
        public ActionResult Index()
        {
            var kala = _Kala_Service.GetAllKalas();
            var brand = _Brand_Service.GetAllBrands();
 
            var kalaviewmodel = EntityMapper.Map<List<KalaViewModel>>(kala, brand);
            return View(kalaviewmodel);
        }
 
 protected override void Configure()
        {
            Mapper.CreateMap<Kala, KalaViewModel>()
            .ForMember(des => des. Brand_Name, op => op.MapFrom(src =>     src.Brand.Brand_Name) );
        }
  کد پایین از لحاظ منطقی هم درست نیست
map کردن Brand با    KalaViewModel  معنایی نداره

‫۱۱ سال و ۷ ماه قبل، یکشنبه ۲۰ اسفند ۱۳۹۱، ساعت ۱۴:۲۵
یک سوال خدمت شما داشتم اینکه :

وقتی بخوایم از 2 جدول متفاوت جستجو کنیم به نظر شما اطلاعات هر جدول را جداگانه ایندکس کنیم(منظورم همان کاری که متد CreateFullTextIndex شما انجام میده) یا خیر؟
البته منظور دو جدولی که با هم رابطه دارند.


چندتا لینک در مورد لوسین:

  ممنون