internal DatastoreContents(ContentsType type, AzureDataLakeSection azureDataLake, AzureMySqlSection azureMySql, AzurePostgreSqlSection azurePostgreSql, AzureSqlDatabaseSection azureSqlDatabase, AzureStorageSection azureStorage, GlusterFsSection glusterFs)
 {
     Type             = type;
     AzureDataLake    = azureDataLake;
     AzureMySql       = azureMySql;
     AzurePostgreSql  = azurePostgreSql;
     AzureSqlDatabase = azureSqlDatabase;
     AzureStorage     = azureStorage;
     GlusterFs        = glusterFs;
 }
 public void Load(ProtoBuf.ItemContainer container)
 {
     using (TimeWarning.New("ItemContainer.Load"))
     {
         uid      = container.UID;
         capacity = container.slots;
         List <Item> obj = itemList;
         itemList        = Pool.GetList <Item>();
         temperature     = container.temperature;
         flags           = (Flag)container.flags;
         allowedContents = (ContentsType)((container.allowedContents == 0) ? 1 : container.allowedContents);
         onlyAllowedItem = ((container.allowedItem != 0) ? ItemManager.FindItemDefinition(container.allowedItem) : null);
         maxStackSize    = container.maxStackSize;
         availableSlots.Clear();
         for (int i = 0; i < container.availableSlots.Count; i++)
         {
             availableSlots.Add((ItemSlot)container.availableSlots[i]);
         }
         using (TimeWarning.New("container.contents"))
         {
             foreach (ProtoBuf.Item content in container.contents)
             {
                 Item created = null;
                 foreach (Item item in obj)
                 {
                     if (item.uid == content.UID)
                     {
                         created = item;
                         break;
                     }
                 }
                 created = ItemManager.Load(content, created, isServer);
                 if (created != null)
                 {
                     created.parent   = this;
                     created.position = content.slot;
                     Insert(created);
                 }
             }
         }
         using (TimeWarning.New("Delete old items"))
         {
             foreach (Item item2 in obj)
             {
                 if (!itemList.Contains(item2))
                 {
                     item2.Remove();
                 }
             }
         }
         dirty = true;
         Pool.FreeList(ref obj);
     }
 }
 public void ServerInitialize(Item parentItem, int iMaxCapacity)
 {
     parent   = parentItem;
     capacity = iMaxCapacity;
     uid      = 0u;
     isServer = true;
     if (allowedContents == (ContentsType)0)
     {
         allowedContents = ContentsType.Generic;
     }
     MarkDirty();
 }
    void Start()
    {
        if (!GlobalOptions.GetBool("elementalShields"))
        {
            switch (type)
            {
            case ContentsType.ShieldElectricity:
            case ContentsType.ShieldBubble:
            case ContentsType.ShieldFire:
                type = ContentsType.Shield;
                break;
            }
        }

        animator.Play(ContentsAnimations[(int)type]);
    }
 public EmailTemplateData(
     string fileName,
     string?from,
     string[] cc,
     string[] bcc,
     string subject,
     bool isEnabled,
     ContentsType contentsType,
     string contents)
 {
     FileName     = fileName;
     From         = from;
     Cc           = cc;
     Bcc          = bcc;
     Subject      = subject;
     IsEnabled    = isEnabled;
     ContentsType = contentsType;
     Contents     = contents;
 }
Exemple #6
0
        public void LoadFromXml(XmlDocument document)
        {
            XmlNodeList nodes = document.SelectNodes(string.Format("/Repositories/Repository/Items/{0}", ContentsType.Name));

            foreach (XmlNode node in nodes)
            {
                T item            = Create();
                PropertyInfo[] pi = ContentsType.GetProperties();
                foreach (XmlNode propName in node.ChildNodes)
                {
                    PropertyInfo p = pi.FirstOrDefault(x => x.Name == propName.Name);
                    if (p != null)
                    {
                        string refType = propName.AttributeValueOrDefault("From");
                        if (string.IsNullOrEmpty(refType))
                        {
                            object value;
                            if (p.PropertyType.IsEnum)
                            {
                                value = Enum.Parse(p.PropertyType, propName.InnerText);
                            }
                            else
                            {
                                value = Convert.ChangeType(propName.InnerText, p.PropertyType);
                            }

                            p.SetValue(item, value, null);
                        }
                        else
                        {
                            IPropertyRepository repo = owner.Get(refType);
                            Entity e = repo.Objects.OfType <Entity>().FirstOrDefault(x => x.Key() == propName.InnerText);
                            p.SetValue(item, e, null);
                        }
                    }
                }

                Add(item);
            }
        }
Exemple #7
0
        /// <summary>
        /// Метод вызывается при удалении объекта из какой-либо коллекции и предназначен
        /// обновления зависимых объектов (объектов помеченых атрибутом DependenceAttribute).
        /// </summary>
        /// <param name="removingItem">Удаляемый объект.</param>
        void RemoveDependence(Entity removingItem)
        {
            IDictionary <PropertyInfo, DependenceAttribute> properties = ContentsType.GetProperties <DependenceAttribute>();

            if (properties.Count == 0)
            {
                return;
            }

            foreach (T item in ItemsWithoutFilters)
            {
                foreach (PropertyInfo p in properties.Keys)
                {
                    object propValue = p.GetValue(item, null);
                    if (propValue == null)
                    {
                        continue;
                    }

                    if (propValue.GetType().GetInterface("IList") != null)
                    {
                        IList list  = (IList)propValue;
                        Stack stack = new Stack();
                        foreach (object obj in list)
                        {
                            if (ReferenceEquals(obj, removingItem))
                            {
                                if (properties[p].Action == DependenceAction.Nothing)
                                {
                                    throw new RepositoryException(string.Format(Strings.DeleteEntityError, removingItem.ToString(), item.ToString()), RepoErrors.EntityDependenceError, removingItem);
                                }
                                else
                                {
                                    stack.Push(obj);
                                }
                            }
                            else
                            {
                                Entity entity = obj as Entity;
                                if (entity != null)
                                {
                                    if (entity.ContainsObject(removingItem))
                                    {
                                        if (properties[p].Action == DependenceAction.Nothing)
                                        {
                                            throw new RepositoryException(string.Format(Strings.DeleteEntityError, removingItem.ToString(), item.ToString()), RepoErrors.EntityDependenceError, removingItem);
                                        }
                                        else
                                        {
                                            stack.Push(obj);
                                        }
                                    }
                                }
                            }
                        }

                        if (stack.Count > 0)
                        {
                            while (stack.Count > 0)
                            {
                                list.Remove(stack.Pop());
                            }

                            UpdateObjectInternal(item, ObjectAction.Modify);
                        }
                    }
                    else
                    {
                        if (ReferenceEquals(propValue, removingItem))
                        {
                            switch (properties[p].Action)
                            {
                            case DependenceAction.SetNull:
                                p.SetValue(item, null, null);
                                owner.Get <T>().Update(item);
                                break;

                            case DependenceAction.Delete:
                                owner.Get <T>().Remove(item);
                                break;

                            case DependenceAction.Nothing:
                                throw new RepositoryException(string.Format(Strings.DeleteEntityError, removingItem.ToString(), item.ToString()), RepoErrors.EntityDependenceError, removingItem);

                            default:
                                throw new Exception("Invalid value for DependenceAction");
                            }
                        }
                    }
                }
            }
        }
 public DatastoreContents(ContentsType type)
 {
     Type = type;
 }