Пример #1
0
        private Guid GetId(IPluginExecutionContext context, string entityName)
        {
            switch (context.MessageName)
            {
            case MessageName.Create:
                if (context.OutputParameters.Contains(ParameterName.Id))
                {
                    return((Guid)context.OutputParameters[ParameterName.Id]);
                }
                break;

            case MessageName.Update:
                if (context.InputParameters[ParameterName.Target] is DynamicEntity)
                {
                    Key key = (Key)((DynamicEntity)context.InputParameters[ParameterName.Target]).Properties[entityName + "id"];
                    return(key.Value);
                }
                break;

            case MessageName.Delete:
                if (context.InputParameters[ParameterName.Target] is Moniker)
                {
                    Moniker monikerId = (Moniker)context.InputParameters[ParameterName.Target];
                    return(monikerId.Id);
                }
                break;
            }

            return(Guid.Empty);
        }
Пример #2
0
        private void SetVersionWindowsStore()
        {
            if (Moniker.StartsWith("netcore [", true, CultureInfo.InvariantCulture))
            {
                // netcore [netcore45]
                var startIndex = Moniker.IndexOf("[netcore", StringComparison.Ordinal);
                var endIndex   = Moniker.IndexOf("]", StringComparison.Ordinal);

                if (endIndex > 0)
                {
                    var ver = Moniker.Substring(startIndex + 8, endIndex - startIndex - 8);
                    Version = VersionNumberFormatter.Format(ver);
                }
            }
            else
            {
                // netcore451 [win81]
                // netcore451
                var startIndex = Moniker.IndexOf("[", StringComparison.Ordinal);

                if (startIndex < 1)
                {
                    Version = VersionNumberFormatter.Format(Moniker.Substring(7));
                }
                else
                {
                    Version = VersionNumberFormatter.Format(Moniker.Substring(7, startIndex - 7));
                }
            }
        }
Пример #3
0
        private void SetVersionUniversalWindowsPlatform()
        {
            if (Moniker.StartsWith("uap [", true, CultureInfo.InvariantCulture))
            {
                // uap [uap10.0]
                var startIndex = Moniker.IndexOf("[uap", StringComparison.Ordinal);
                var endIndex   = Moniker.IndexOf("]", StringComparison.Ordinal);

                if (endIndex > 0)
                {
                    var ver = Moniker.Substring(startIndex + 4, endIndex - startIndex - 4);
                    Version = VersionNumberFormatter.Format(ver);
                }
            }
            else
            {
                // uap10.0 [win10] [netcore50]
                var startIndex = Moniker.IndexOf("[", StringComparison.Ordinal);

                if (startIndex < 1)
                {
                    Version = VersionNumberFormatter.Format(Moniker.Substring(3));
                }
                else
                {
                    Version = VersionNumberFormatter.Format(Moniker.Substring(3, startIndex - 3));
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Get a specific PropertyBag value from a moniker
        /// </summary>
        /// <param name="sPropName">The name of the value to retrieve</param>
        /// <returns>String or null on error</returns>
        public string GetPropBagValue(string sPropName)
        {
            string ret;
            object bagObj = null;

            try
            {
                var bagId = typeof(IPropertyBag).GUID;
                Moniker.BindToStorage(null, null, ref bagId, out bagObj);

                var bag = (IPropertyBag)bagObj;

                var hr = bag.Read(sPropName, out object val, null);
                DsError.ThrowExceptionForHR(hr);

                ret = val as string;
            }
            catch
            {
                ret = null;
            }
            finally
            {
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                }
            }

            return(ret);
        }
Пример #5
0
        private void SetVersionWindowsPhone()
        {
            if (Moniker.StartsWith("wpa", true, CultureInfo.InvariantCulture))
            {
                // wpa81
                Version = VersionNumberFormatter.Format(Moniker.Substring(3));
            }
            else if (Moniker.StartsWith("wp [", true, CultureInfo.InvariantCulture))
            {
                // wp [wp71]
                var startIndex = Moniker.IndexOf("[wp", StringComparison.Ordinal);
                var endIndex   = Moniker.IndexOf("]", StringComparison.Ordinal);

                if (endIndex < 1)
                {
                    Version = string.Empty;
                }
                else
                {
                    var ver = Moniker.Substring(startIndex + 3, endIndex - startIndex - 3);
                    Version = VersionNumberFormatter.Format(ver);
                }
            }
            else
            {
                Version = VersionNumberFormatter.Format(Moniker.Substring(2));
            }
        }
    public static void SetHtmlContent(this System.Windows.Forms.WebBrowser webBrowser, string html, string baseUrl)
    {
        webBrowser.Navigate("about:blank");
        var browser = (IWebBrowser2)webBrowser.ActiveXInstance;
        var result  = CreateStreamOnHGlobal(Marshal.StringToHGlobalAuto(html), true, out IStream stream);

        if ((result != 0) || (stream == null))
        {
            return;
        }
        var persistentMoniker = browser.Document as IPersistMoniker;

        if (persistentMoniker == null)
        {
            return;
        }
        IBindCtx bindContext = null;

        CreateBindCtx((uint)0, out bindContext);
        if (bindContext == null)
        {
            return;
        }
        var loader = new Moniker(baseUrl, html);

        persistentMoniker.Load(1, loader, bindContext, (uint)0);
        stream = null;
    }
Пример #7
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         IBindCtx bind_context = COMUtilities.CreateBindCtx(0);
         if (checkBoxParseComposite.Checked)
         {
             foreach (string m in textBoxMoniker.Text.Split('!'))
             {
                 IMoniker moniker = ParseMoniker(bind_context, m);
                 if (Moniker != null)
                 {
                     Moniker.ComposeWith(moniker, false, out moniker);
                 }
                 Moniker = moniker;
             }
         }
         else
         {
             Moniker = ParseMoniker(bind_context, textBoxMoniker.Text);
         }
         MonikerString = textBoxMoniker.Text;
         BindContext   = bind_context;
         DialogResult  = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         Program.ShowError(this, ex);
     }
 }
        protected override void OnUnresolvedMoniker(SerializationResult serializationResult, Moniker moniker)
        {
            /*
            if (moniker.Link is SerializationClassReferencesChildren ||
                moniker.Link is SerializationClassReferencesAttributes ||
                moniker.Link is DomainClassReferencesBaseClass ||
                moniker.Link is DomainRelationshipReferencesBaseRelationship ||
                moniker.Link is TreeNodeReferencesInheritanceNodes ||
                moniker.Link is TreeNodeReferencesEmbeddingRSNodes ||
                moniker.Link is TreeNodeReferencesReferenceRSNodes ||
                moniker.Link is TreeNodeReferencesShapeClassNodes)
            {*/
            if( moniker.Link != null )
            {
                // TODO
                string name = moniker.Link.ToString() + " - " + moniker.MonikerName;
                moniker.DeleteLink();

                SerializationUtilities.AddMessage(serializationResult, moniker.Location,
                    SerializationMessageKind.Warning, "Moniker could not be resolved; The link was deleted from the model. " + name,
                        moniker.Line, moniker.Column);
            }
            else
                base.OnUnresolvedMoniker(serializationResult, moniker);
        }
 public static bool IsMonikerHero(Moniker moniker)
 {
     return(moniker == Moniker.Warrior ||
            moniker == Moniker.WarriorChakra ||
            moniker == Moniker.Cleric ||
            moniker == Moniker.ClericChakra ||
            moniker == Moniker.Wizard ||
            moniker == Moniker.WizardChakra);
 }
Пример #10
0
        public bool Equals(ITargetFramework obj)
        {
            if (obj != null)
            {
                return(Moniker.Equals(obj.Moniker, StringComparison.OrdinalIgnoreCase));
            }

            return(false);
        }
    private BtlCtrlCharacter MakeTutCharacter(Moniker moniker, int id, int level, bool isActive)
    {
        BtlCtrlCharacter character = _dataFiller.FillCharacterData(moniker, level, BattleControllerType.Tutorial_Zahak);

        character.id       = id;
        character.isActive = isActive;

        return(character);
    }
Пример #12
0
        private void SetTypeAndVersion()
        {
            FrameworkType = TargetFrameworkType.Unknown;
            Version       = string.Empty;

            if (Moniker.StartsWith("net6", true, CultureInfo.InvariantCulture) ||
                Moniker.StartsWith("net5", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.Core;
                SetVersionDotNet5Plus();
            }
            else if (Moniker.StartsWith("netcoreapp", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.Core;
                Version       = Moniker.Substring(10);
            }
            else if (Moniker.StartsWith("netstandard", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.Standard;
                Version       = Moniker.Substring(11);
            }
            else if (Moniker.StartsWith("netmf", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.MicroFramework;
            }
            else if (Moniker.StartsWith("v", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.Framework;
                Version       = Moniker.Substring(1);
            }
            else if (Moniker.StartsWith("sl", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.Silverlight;
                Version       = Moniker.Substring(2);
            }
            else if (Moniker.StartsWith("wp", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.WindowsPhone;
                SetVersionWindowsPhone();
            }
            else if (Moniker.StartsWith("uap", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.UniversalWindowsPlatform;
                SetVersionUniversalWindowsPlatform();
            }
            else if (Moniker.StartsWith("netcore", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.WindowsStore;
                SetVersionWindowsStore();
            }
            else if (Moniker.StartsWith("net", true, CultureInfo.InvariantCulture))
            {
                FrameworkType = TargetFrameworkType.Framework;
                Version       = VersionNumberFormatter.Format(Moniker.Substring(3));
            }
        }
Пример #13
0
    public static bool IsCharNewAndUnseen(Moniker moniker)
    {
        if (!DoesAnyUnseenNewCharExists())
        {
            return(false);
        }

        string key = KEY__NEW_CHAR + moniker;

        return(DataAccessManager.HasKey(key));
    }
Пример #14
0
 /// <summary>
 ///  Need to override this to ensure it can be hashed correctly
 /// </summary>
 public override int GetHashCode()
 {
     if (Moniker == null)
     {
         return(string.Empty.GetHashCode());
     }
     else
     {
         return(Moniker.ToLowerInvariant().GetHashCode());
     }
 }
Пример #15
0
        private void SetVersionDotNet5Plus()
        {
            var segments = Moniker.Split('-');

            Version = segments[0].Substring(3);                     // net5.0

            if (segments.Length > 1)
            {
                // net5.0-windows
                OperatingSystem = segments[1];
            }
        }
        public static List <Record> CreateRecords(this DbFactory f, int userId, DateTime from, DateTime until, int count, Action <Record> overrides = null)
        {
            var storage  = f.CreateStorage(userId);
            var category = f.Create <Category>(_ => _.UserId = userId);
            var result   = new List <Record>();

            // create boundary values
            if (count >= 2)
            {
                result.Add(f.Create <Record>(item =>
                {
                    item.CategoryId = category.Id;
                    item.StorageId  = storage.Id;
                    item.CurrencyId = storage.CurrencyId;
                    item.Date       = from;
                    item.UserId     = userId;
                    overrides?.Invoke(item);
                }));
                result.Add(f.Create <Record>(item =>
                {
                    item.CategoryId = category.Id;
                    item.StorageId  = storage.Id;
                    item.CurrencyId = storage.CurrencyId;
                    item.Date       = until;
                    item.UserId     = userId;
                    overrides?.Invoke(item);
                }));
                count -= 2;
            }

            while (count-- > 0)
            {
                result.Add(f.Create <Record>(item =>
                {
                    item.CategoryId = category.Id;
                    item.StorageId  = storage.Id;
                    item.CurrencyId = storage.CurrencyId;
                    item.Date       = Moniker.DateTimeBetween(from, until);
                    item.UserId     = userId;
                    overrides?.Invoke(item);
                }));
            }

            return(result);
        }
Пример #17
0
    public static void TrySetCharAsNew(Moniker moniker)
    {
        string key = KEY__NEW_CHAR + moniker;

        if (DataAccessManager.HasKey(key))
        {
            return;
        }

        DataAccessManager.SaveStringToDisk(key, moniker.ToString());

        NumOfUnseenNewChars++;

        if (Event_CharIsNewStateChanged != null)
        {
            Event_CharIsNewStateChanged(moniker, true);
        }
    }
Пример #18
0
    public static void TryDeleteCharAsNew(Moniker moniker)
    {
        string key = KEY__NEW_CHAR + moniker;

        if (!DataAccessManager.HasKey(key))
        {
            return;
        }

        DataAccessManager.DeleteStringFromDisk(key);

        NumOfUnseenNewChars--;

        if (Event_CharIsNewStateChanged != null)
        {
            Event_CharIsNewStateChanged(moniker, false);
        }
    }
Пример #19
0
    //
    /// <summary>
    /// Make a record inactive
    /// </summary>
    /// <param name="dynamicEntityObject">Entity</param>
    /// <param name="service">CrmService Proxy</param>
    public static void SetInactive(this DynamicEntity dynamicEntityObject, CrmService crmServiceProxy)
    {
        try
        {
            SetStateDynamicEntityRequest setInactiveRequest = new SetStateDynamicEntityRequest();
            Key     recordGuid    = (Key)dynamicEntityObject[dynamicEntityObject.Name + "id"];
            Moniker entityMoniker = new Moniker(dynamicEntityObject.Name, recordGuid.Value);
            //HACK: Might not work always since the status are different for quite a few entities
            setInactiveRequest.Entity = entityMoniker;
            setInactiveRequest.Status = -1;
            setInactiveRequest.State  = "Inactive";

            SetStateDynamicEntityResponse setInactiveResponse =
                (SetStateDynamicEntityResponse)crmServiceProxy.Execute(setInactiveRequest);
        }
        catch (System.Web.Services.Protocols.SoapException)
        {
            throw;
        }
    }
Пример #20
0
 private void CameraResolutionComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     DisposeCamera();
     if (Moniker != null && Resolution != null)
     {
         try
         {
             NetCamera = new NetCameraProxy(Moniker, Resolution);
             Settings.Get <Settings>().Write(Settings.LAST_USED, Settings.CAMERA_RESOLUTION, Resolution.ToString());
             Guid id;
             Moniker.GetClassID(out id);
             Settings.Get <Settings>().Write(Settings.LAST_USED, Settings.CAMERA_DEVICE, id.ToString());
             Proxy = NetCamera;
             this.CameraControl.Proxy = Proxy;
         }
         catch
         {
         }
     }
 }
Пример #21
0
    /// <summary>
    /// Sets the state for the record
    /// </summary>
    /// <param name="dynamicEntityObject"></param>
    /// <param name="service">CrmService</param>
    /// <param name="status">status code</param>
    /// <param name="state">Status text</param>
    public static void SetState(this DynamicEntity dynamicEntityObject, ICrmService service, int status, String state)
    {
        try
        {
            SetStateDynamicEntityRequest setInactiveRequest = new SetStateDynamicEntityRequest();

            Key     recordGuid    = (Key)dynamicEntityObject[dynamicEntityObject.Name + "id"];
            Moniker entityMoniker = new Moniker(dynamicEntityObject.Name, recordGuid.Value);
            setInactiveRequest.Entity = entityMoniker;
            setInactiveRequest.Status = status;
            setInactiveRequest.State  = state;

            SetStateDynamicEntityResponse setInactiveResponse =
                (SetStateDynamicEntityResponse)service.Execute(setInactiveRequest);
        }
        catch (System.Web.Services.Protocols.SoapException)
        {
            throw;
        }
    }
        private bool VisitRolePlayers(ElementLink link)
        {
            bool keepVisiting = true;
            DomainRelationshipInfo domainRelInfo = link.GetDomainRelationship();

            IList <DomainRoleInfo> domainRoles = domainRelInfo.DomainRoles;

            for (int i = 0; i < domainRoles.Count && keepVisiting; i++)
            {
                DomainRoleInfo role = domainRoles[i];

                // Since GetRolePlayer will do demand-loading, we first need to test here whether
                // role supports demand loading and if it is, don't load if not asked to.
                if (this.BypassDemandLoading)
                {
                    Moniker rolePlayerMoniker = role.GetRolePlayerMoniker(link);
                    if (rolePlayerMoniker != null && rolePlayerMoniker.ModelElement == null)
                    {
                        // skip this role if it's not resolved yet
                        continue;
                    }
                }

                ModelElement rolePlayer = role.GetRolePlayer(link);

                // Find each roleplayer and add them to the queue list
                // RolePlayer might be null if it is an unresolved moniker
                if ((rolePlayer != link) &&
                    (rolePlayer != null) &&
                    !Visited(rolePlayer) &&
                    (Filter.ShouldVisitRolePlayer(this, link, link, role, rolePlayer) == VisitorFilterResult.Yes))
                {
                    keepVisiting = DoVisitElement(rolePlayer);
                }
            }
            return(keepVisiting);
        }
Пример #23
0
 /// <nodoc/>
 public override int GetHashCode()
 {
     return(Moniker.GetHashCode());
 }
Пример #24
0
 public override int GetHashCode()
 {
     return(HashHelpers.CombineHashes(Moniker.GetHashCode(), Attributes.GetHashCode()));
 }
Пример #25
0
        /// <summary>
        /// Retrieves EntityId from the Context
        /// Create,Update,Delete,SetState,Assign,DeliverIncoming
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static Guid GetEntityId(IPluginExecutionContext context)
        {
            switch (context.MessageName)
            {
            case MessageName.Create:
            case MessageName.DeliverIncoming:
                if (context.Stage == MessageProcessingStage.BeforeMainOperationOutsideTransaction)
                {
                    //throw new InvalidPluginExecutionException("EntityId is not available in PreCreate");
                    return(Guid.Empty);
                }
                else
                {
                    //CreateResponse r;
                    //r.id;
                    if (context.OutputParameters.Contains(ParameterName.Id))
                    {
                        return((Guid)context.OutputParameters[ParameterName.Id]);
                    }

                    //DeliverIncomingEmailResponse r;
                    //r.EmailId;
                    if (context.OutputParameters.Contains(ParameterName.EmailId))
                    {
                        return((Guid)context.OutputParameters[ParameterName.EmailId]);
                    }
                }
                break;

            case MessageName.Update:
                //context.InputParameters.Contains(ParameterName.Target)
                IMetadataService      metadataService = context.CreateMetadataService(false);
                RetrieveEntityRequest rar             = new RetrieveEntityRequest();
                rar.LogicalName = context.PrimaryEntityName;
                rar.EntityItems = EntityItems.IncludeAttributes;
                RetrieveEntityResponse resp = (RetrieveEntityResponse)metadataService.Execute(rar);
                string keyName = resp.EntityMetadata.PrimaryKey;

                //UpdateRequest u;
                //TargetUpdateAccount a;
                //a.Account; // This s Dynamic entity
                //u.Target = a;

                // Update
                if (context.InputParameters[ParameterName.Target] is DynamicEntity)
                {
                    Key key = (Key)((DynamicEntity)context.InputParameters[ParameterName.Target]).Properties[keyName];
                    return(key.Value);
                }
                break;

            case MessageName.Delete:
            case MessageName.Assign:
            case MessageName.GrantAccess:
            case MessageName.Handle:
                if (context.InputParameters[ParameterName.Target] is Moniker)
                {
                    Moniker monikerId = (Moniker)context.InputParameters[ParameterName.Target];
                    return(monikerId.Id);
                }
                break;

            case MessageName.SetState:
            case MessageName.SetStateDynamicEntity:
                //SetStateAccountRequest r;
                //r.EntityId; // Guid === Moniker
                //r.AccountState; // State
                //r.AccountStatus; // Status
                return(((Moniker)context.InputParameters.Properties[ParameterName.EntityMoniker]).Id);;

            default:
                if (context.InputParameters.Contains(ParameterName.Target) &&
                    (context.InputParameters[ParameterName.Target] is Moniker))
                {
                    Moniker monikerId = (Moniker)context.InputParameters[ParameterName.Target];
                    return(monikerId.Id);
                }
                //Try by best route else fail
                //throw new InvalidPluginExecutionException("GetEntityId could not extract the Guid from Context");
                return(Guid.Empty);
            }
            //throw new InvalidPluginExecutionException("GetEntityId could not extract the Guid from Context");
            return(Guid.Empty);
        }
Пример #26
0
        private static void DefineModels(DbFactory f)
        {
            f.Define <UserModel>(e =>
            {
                e.Name     = Moniker.UserName;
                e.Password = Moniker.UserPassword;
            });

            f.Define <CategoryModel>(e =>
            {
                e.Name = Moniker.Category;
            });

            f.Define <CurrencyModel>(e =>
            {
                e.Name     = Moniker.Currency;
                e.Code     = Moniker.CurrencyCode;
                e.Symbol   = Moniker.CurrencySymbol;
                e.IsActive = true;
                e.IsMain   = false;
            });

            f.Define <StorageGroupModel>(e =>
            {
                e.Name = Moniker.StorageGroup;
            });

            f.Define <StorageModel>(e =>
            {
                e.Name  = "Storage";
                e.Value = Moniker.Digit;
            });

            f.Define <CurrencyExchangeRateModel>(e =>
            {
                e.Rate = Moniker.LimitedDigit(30);
            });

            f.Define <DebtModel>(e =>
            {
                e.Description = "Take Debt";
                e.DebtType    = DebtType.TakeBorrow;
                e.TakingDate  = DateTime.Today;
                e.Value       = Moniker.Digit;
            });

            f.Define <RecordModel>(e =>
            {
                e.Description = "Record";
                e.RecordType  = RecordType.Expense;
                e.Date        = DateTime.Now;
                e.Value       = Moniker.Digit;
            });

            f.Define <LimitModel>(e =>
            {
                e.Value = Moniker.Digit;
            });

            f.Define <MoneyTransferEventModel>(e =>
            {
                e.Description          = "MoneyTransferEvent";
                e.Value                = Moniker.Digit;
                e.EventState           = EventState.Active;
                e.AutoExecution        = false;
                e.ConfirmBeforeExecute = false;
            });

            f.Define <RepayDebtEventModel>(e =>
            {
                e.Description          = "RepayDebtEvent";
                e.Value                = Moniker.Digit;
                e.EventState           = EventState.Active;
                e.AutoExecution        = false;
                e.ConfirmBeforeExecute = false;
            });

            f.Define <SimpleEventModel>(e =>
            {
                e.Description          = "RepayDebtEvent";
                e.Value                = Moniker.Digit;
                e.EventState           = EventState.Active;
                e.AutoExecution        = false;
                e.ConfirmBeforeExecute = false;
                e.RecordType           = RecordType.Expense;
            });
        }
        public override ModelElement ResolveMoniker(Moniker moniker)
        {
            Microsoft.VisualStudio.Modeling.ModelElement modelElement;

            #region PropertyGridEditor
            if (moniker.DomainRelationshipInfo.Id == DomainTypeReferencesPropertyGridEditor.DomainClassId)
            {
                propertyGridEditorTypeLookup.TryGetValue(moniker.MonikerName, out modelElement);
                if (modelElement == null)
                {
                    string[] name = moniker.MonikerName.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                    if (name.Length > 1)
                    {
                        string modelName = name[0];
                        string editorName = name[1];

                        MetaModel model = FindMetaModel(moniker.Store, modelName);
                        if (model != null)
                        {
                            foreach (PropertyGridEditor editor in model.PropertyGridEditors)
                                if (editor.Name == editorName)
                                {
                                    modelElement = editor;
                                    propertyGridEditorTypeLookup[moniker.MonikerName] = editor;
                                    break;
                                }
                        }
                    }

                    return modelElement;
                }
                else 
                    return modelElement;
                
            }
            #endregion

            #region DomainEnumeration and ExternalType
            if (moniker.DomainRelationshipInfo.Id == DomainPropertyReferencesType.DomainClassId)
            {
                typeLookup.TryGetValue(moniker.MonikerName, out modelElement);
                if (modelElement == null)
                {
                    string[] name = moniker.MonikerName.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                    if (name.Length > 2)
                    {
                        string modelName = name[0];
                        string namespaceStr = name[1];
                        string editorName = name[2];

                        MetaModel model = FindMetaModel(moniker.Store, modelName);
                        if (model != null)
                        {
                            foreach (DomainType t in model.DomainTypes)
                                if (t.Name == editorName && t.Namespace == namespaceStr)
                                {
                                    modelElement = t;
                                    typeLookup[moniker.MonikerName] = t;
                                    break;
                                }
                        }
                    }

                    return modelElement;
                }
                else
                    return modelElement;


            }
            #endregion

            ModelElement m = base.ResolveMoniker(moniker);
            if (m == null)
            {
                try
                {
                    Guid guid = new Guid(moniker.MonikerName);
                    m = moniker.Store.ElementDirectory.FindElement(guid);
                }
                catch { }

            }
            if (m == null)
            {

            }
            return m;
        }
Пример #28
0
        private static void DefineEntities(DbFactory f)
        {
            f.Define <User>(e =>
            {
                e.Name          = Moniker.UserName;
                e.Password      = Moniker.UserPassword;
                e.LastUsageDate = DateTime.Now;
            });

            f.Define <Category>(e =>
            {
                e.Name     = Moniker.Category;
                e.IsActive = true;
            });

            f.Define <Currency>(e =>
            {
                e.Name     = Moniker.Currency;
                e.Code     = Moniker.CurrencyCode;
                e.Symbol   = Moniker.CurrencySymbol;
                e.IsActive = true;
                e.IsMain   = false;
                e.CurrencySymbolAlignment = CurrencySymbolAlignment.Right;
            });

            f.Define <CurrencyExchangeRate>(e =>
            {
                e.Rate = Moniker.LimitedDigit(30);
            });

            f.Define <StorageGroup>(e =>
            {
                e.Name = Moniker.StorageGroup;
            });

            f.Define <Storage>(e =>
            {
                e.Name      = "Storage";
                e.Value     = Moniker.Digit;
                e.IsVisible = true;
            });

            f.Define <Debt>(e =>
            {
                e.Description = "Take Debt";
                e.DebtType    = DebtType.TakeBorrow;
                e.TakingDate  = DateTime.Today;
                e.Value       = Moniker.Digit;
                e.IsRepaid    = false;
            });

            f.Define <Record>(e =>
            {
                e.Description = "Record";
                e.RecordType  = RecordType.Expense;
                e.Date        = DateTime.Now;
                e.Value       = Moniker.Digit;
            });

            f.Define <MoneyTransfer>(e =>
            {
                e.Date                       = DateTime.Now;
                e.Description                = "MoneyTransfer";
                e.Value                      = Moniker.Digit;
                e.CurrencyExchangeRate       = 1;
                e.TakeCommissionFromReceiver = false;
                e.CommissionType             = CommissionType.Currency;
            });

            f.Define <Limit>(e =>
            {
                e.Value       = Moniker.Digit;
                e.Description = "Limit";
                e.DateFrom    = DateTime.Today.AddDays(1);
                e.DateUntil   = e.DateFrom.Date;
            });

            DefineEventEntities(f);
            DefineSettingsEntities(f);
        }
Пример #29
0
 public RewardCardData(int count, Moniker moniker)
 {
     this.count   = count;
     this.moniker = moniker;
 }
Пример #30
0
        protected override void OnUnresolvedMoniker(SerializationResult serializationResult, Moniker moniker)
        {
            /*
             * if (moniker.Link is SerializationClassReferencesChildren ||
             *  moniker.Link is SerializationClassReferencesAttributes ||
             *  moniker.Link is DomainClassReferencesBaseClass ||
             *  moniker.Link is DomainRelationshipReferencesBaseRelationship ||
             *  moniker.Link is TreeNodeReferencesInheritanceNodes ||
             *  moniker.Link is TreeNodeReferencesEmbeddingRSNodes ||
             *  moniker.Link is TreeNodeReferencesReferenceRSNodes ||
             *  moniker.Link is TreeNodeReferencesShapeClassNodes)
             * {*/
            if (moniker.Link != null)
            {
                // TODO
                string name = moniker.Link.ToString() + " - " + moniker.MonikerName;
                moniker.DeleteLink();

                SerializationUtilities.AddMessage(serializationResult, moniker.Location,
                                                  SerializationMessageKind.Warning, "Moniker could not be resolved; The link was deleted from the model. " + name,
                                                  moniker.Line, moniker.Column);
            }
            else
            {
                base.OnUnresolvedMoniker(serializationResult, moniker);
            }
        }
Пример #31
0
        public override ModelElement ResolveMoniker(Moniker moniker)
        {
            Microsoft.VisualStudio.Modeling.ModelElement modelElement;

            #region PropertyGridEditor
            if (moniker.DomainRelationshipInfo.Id == DomainTypeReferencesPropertyGridEditor.DomainClassId)
            {
                propertyGridEditorTypeLookup.TryGetValue(moniker.MonikerName, out modelElement);
                if (modelElement == null)
                {
                    string[] name = moniker.MonikerName.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                    if (name.Length > 1)
                    {
                        string modelName  = name[0];
                        string editorName = name[1];

                        MetaModel model = FindMetaModel(moniker.Store, modelName);
                        if (model != null)
                        {
                            foreach (PropertyGridEditor editor in model.PropertyGridEditors)
                            {
                                if (editor.Name == editorName)
                                {
                                    modelElement = editor;
                                    propertyGridEditorTypeLookup[moniker.MonikerName] = editor;
                                    break;
                                }
                            }
                        }
                    }

                    return(modelElement);
                }
                else
                {
                    return(modelElement);
                }
            }
            #endregion

            #region DomainEnumeration and ExternalType
            if (moniker.DomainRelationshipInfo.Id == DomainPropertyReferencesType.DomainClassId)
            {
                typeLookup.TryGetValue(moniker.MonikerName, out modelElement);
                if (modelElement == null)
                {
                    string[] name = moniker.MonikerName.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                    if (name.Length > 2)
                    {
                        string modelName    = name[0];
                        string namespaceStr = name[1];
                        string editorName   = name[2];

                        MetaModel model = FindMetaModel(moniker.Store, modelName);
                        if (model != null)
                        {
                            foreach (DomainType t in model.DomainTypes)
                            {
                                if (t.Name == editorName && t.Namespace == namespaceStr)
                                {
                                    modelElement = t;
                                    typeLookup[moniker.MonikerName] = t;
                                    break;
                                }
                            }
                        }
                    }

                    return(modelElement);
                }
                else
                {
                    return(modelElement);
                }
            }
            #endregion

            ModelElement m = base.ResolveMoniker(moniker);
            if (m == null)
            {
                try
                {
                    Guid guid = new Guid(moniker.MonikerName);
                    m = moniker.Store.ElementDirectory.FindElement(guid);
                }
                catch { }
            }
            if (m == null)
            {
            }
            return(m);
        }
 public static List <Record> CreateRecords(this DbFactory f, int userId, DateTime from, DateTime until, Action <Record> overrides = null)
 {
     return(CreateRecords(f, userId, from, until, Moniker.LimitedDigit(2, 5), overrides));
 }