public virtual void DoAnaliseDbContext() { if (SelectedCodeElement == null) { if (UiCommandButtonVisibility == Visibility.Visible) { if (_ActionUserControl == null) { _ActionUserControl = new UserControlOneCommand(this); } DefineUiCaptions(); ActionUserControl = _ActionUserControl; if (string.IsNullOrEmpty(UiCommandProppertyName)) { UiCommandProppertyName = UiCommandProppertySufix; OnPropertyChanged("UiCommandProppertyName"); } } } else { DoAnaliseSelectedCodeElement(); } OnPropertyChanged("ActionUserControl"); OnPropertyChanged("SelectedProppertyName"); CheckIsReady(); }
public virtual void DoAnalize() { HasPrimKey = false; SelectedProppertyName = ""; ActionUserControl = null; if (SelectedDbContext != null) { if (SelectedDbContext.CodeElementRef != null) { if (SelectedCodeElement != null) { if (SelectedCodeElement.CodeElementRef != null) { SelectedProppertyName = (SelectedDbContext.CodeElementRef as CodeClass).GetDbContextDbSetPropertyNameHelper(SelectedCodeElement.CodeElementName, SelectedCodeElement.CodeElementFullName); if (string.IsNullOrEmpty(SelectedProppertyName)) { if (_ActionUserControl == null) { _ActionUserControl = new UserControlOneCommand(this); } UiCommandProppertyName = SelectedCodeElement.CodeElementName + UiCommandProppertySufix; DefineUiCaptions(); ActionUserControl = _ActionUserControl; } else { // Primary key analize here FluentAPIKey primKey = new FluentAPIKey(); (SelectedCodeElement.CodeElementRef as CodeClass).CollectPrimaryKeyPropsHelper(primKey, SelectedDbContext.CodeElementRef as CodeClass); if (primKey.KeyProperties != null) { HasPrimKey = primKey.KeyProperties.Count > 0; } if (_PrimKeyUserControl == null) { _PrimKeyUserControl = new UserControlOneCommand(this); } ReDefineUiCaptions(primKey); ActionUserControl = _PrimKeyUserControl; } } } } } OnPropertyChanged("ActionUserControl"); OnPropertyChanged("SelectedProppertyName"); CheckIsReady(); }
public virtual void DoAnaliseSelectedCodeElement() { if (SelectedCodeElement == null) { return; } CodeClass cc = SelectedCodeElement.CodeElementRef as CodeClass; bool hasFunc = false; foreach (CodeElement ce in cc.Members) { if (ce.Kind != vsCMElement.vsCMElementFunction) { continue; } CodeFunction cf = ce as CodeFunction; if (cf.Access != vsCMAccess.vsCMAccessProtected) { continue; } // vsCMFunction fk = cf.FunctionKind; if ("OnModelCreating".Equals(cf.Name)) { hasFunc = true; break; } } if (hasFunc) { ActionUserControl = null; } else { if (_ActionUserControl == null) { _ActionUserControl = new UserControlOneCommand(this); } ReDefineUiCaptions(); ActionUserControl = _ActionUserControl; } }
public override void DoAnaliseDbContext() { if (SelectedCodeElement == null) { ActionUserControl = null; SelectedProppertyName = ""; OnPropertyChanged("ActionUserControl"); OnPropertyChanged("SelectedProppertyName"); CheckIsReady(); return; } CodeClass cc = SelectedCodeElement.CodeElementRef as CodeClass; string nameLookFor1 = "System.Data.Entity.DbSet<" + SelectedViewModelRootClass + ">"; string nameLookFor2 = "Microsoft.EntityFrameworkCore.DbSet<" + SelectedViewModelRootClass + ">"; bool hasProperty = false; foreach (CodeElement ce in cc.Members) { if (ce.Kind != vsCMElement.vsCMElementProperty) { continue; } CodeProperty cp = ce as CodeProperty; if (cp.Access != vsCMAccess.vsCMAccessPublic) { continue; } if (cp.Type == null) { continue; } if (cp.Type.CodeType == null) { continue; } if (cp.Type.CodeType.Kind != vsCMElement.vsCMElementClass) { continue; } if (nameLookFor1.Equals(cp.Type.AsFullName, StringComparison.OrdinalIgnoreCase) || nameLookFor2.Equals(cp.Type.AsFullName, StringComparison.OrdinalIgnoreCase)) { SelectedProppertyName = cp.Name; hasProperty = true; break; } } if (hasProperty) { ActionUserControl = null; } else { if (_ActionUserControl == null) { _ActionUserControl = new UserControlOneCommand(this); } ActionUserControl = _ActionUserControl; SelectedProppertyName = ""; if (SelectedViewModel != null) { UiCommandProppertyName = SelectedViewModel.RootNodeClassName + UiCommandProppertySufix; } else { UiCommandProppertyName = ""; } } OnPropertyChanged("UiCommandProppertyName"); OnPropertyChanged("ActionUserControl"); OnPropertyChanged("SelectedProppertyName"); CheckIsReady(); }