public AssetMemberNodeChangeEventArgs([NotNull] MemberNodeChangeEventArgs e, OverrideType previousOverride, OverrideType newOverride, ItemId itemId)
     : base(e.Member, e.OldValue, e.NewValue)
 {
     PreviousOverride = previousOverride;
     NewOverride      = newOverride;
     ItemId           = itemId;
 }
Exemplo n.º 2
0
        private void UpdateAppointmentWindow(AppointmentWindow appointmentWindow)
        {
            if (_appointmentWindow == null)
            {
                return;
            }
            if (OverrideType.HasFlag(PlanningOverrideType.Window))
            {
                return;
            }

            // take the predefined start and end date of the appointment window
            // only the date portion will vary
            var startTimeSpan = new TimeSpan(AppointmentWindow.WindowStart.Hours,
                                             AppointmentWindow.WindowStart.Minutes,
                                             AppointmentWindow.WindowStart.Seconds);

            WindowStart = new DateTimeOffset(new DateTime(WindowStart.Year, WindowStart.Month, WindowStart.Day), WindowStart.Offset).Add(startTimeSpan);

            var endTimeSpan = new TimeSpan(AppointmentWindow.WindowEnd.Hours,
                                           AppointmentWindow.WindowEnd.Minutes,
                                           AppointmentWindow.WindowEnd.Seconds);

            WindowEnd = new DateTimeOffset(new DateTime(WindowEnd.Year, WindowEnd.Month, WindowEnd.Day), WindowEnd.Offset).Add(endTimeSpan);
        }
Exemplo n.º 3
0
 public AssetContentChangeEventArgs(ContentChangeEventArgs e, OverrideType previousOverride, OverrideType newOverride, ItemId itemId)
     : base(e.Content, e.Index, e.ChangeType, e.OldValue, e.NewValue)
 {
     PreviousOverride = previousOverride;
     NewOverride      = newOverride;
     ItemId           = itemId;
 }
 public AssetItemNodeChangeEventArgs([NotNull] ItemChangeEventArgs e, OverrideType previousOverride, OverrideType newOverride, ItemId itemId)
     : base(e.Collection, e.Index, e.ChangeType, e.OldValue, e.NewValue)
 {
     PreviousOverride = previousOverride;
     NewOverride      = newOverride;
     ItemId           = itemId;
 }
Exemplo n.º 5
0
 internal void SetContentOverride(OverrideType overrideType)
 {
     if (CanOverride)
     {
         contentOverride = overrideType;
     }
 }
 public AssetContentValueChangeOperation(IAssetNode node, ContentChangeType changeType, NodeIndex index, object oldValue, object newValue, OverrideType previousOverride, OverrideType newOverride, ItemId itemId, IEnumerable <IDirtiable> dirtiables)
     : base(node, changeType, index, oldValue, newValue, dirtiables)
 {
     this.previousOverride = previousOverride;
     this.itemId           = itemId;
     this.newOverride      = newOverride;
 }
 public AssetContentChangeEventArgs(ContentChangeEventArgs e, OverrideType previousOverride, OverrideType newOverride, ItemId itemId)
     : base(e.Content, e.Index, e.ChangeType, e.OldValue, e.NewValue)
 {
     PreviousOverride = previousOverride;
     NewOverride = newOverride;
     ItemId = itemId;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetMemberValue"/> struct.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="override">The override.</param>
 /// <param name="overriderItem">The overrider item.</param>
 public AssetMemberValue(object value, OverrideType @override, AssetItem overriderItem)
     : this()
 {
     IsValid       = true;
     Value         = value;
     Override      = @override;
     OverriderItem = overriderItem;
 }
Exemplo n.º 9
0
 internal void SetKeyOverride(OverrideType overrideType, Index index)
 {
     if (CanOverride)
     {
         var id = IndexToId(index);
         SetOverride(overrideType, id, keyOverrides);
     }
 }
Exemplo n.º 10
0
 public void OverrideContent(bool isOverridden)
 {
     if (CanOverride)
     {
         OverrideChanging?.Invoke(this, EventArgs.Empty);
         contentOverride = isOverridden ? OverrideType.New : OverrideType.Base;
         OverrideChanged?.Invoke(this, EventArgs.Empty);
     }
 }
Exemplo n.º 11
0
 // Override oCreature's nType to nValue for oPlayer
 // - oCreature can be a PC
 //
 // nType = NWNX_APPEARANCE_TYPE_APPEARANCE
 // nValue = APPEARANCE_TYPE_* or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_GENDER
 // nValue = GENDER_* or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_HITPOINTS
 // nValue = 0-GetMaxHitPoints(oCreature) or -1 to remove
 // NOTE: This is visual only. Does not change the Examine Window health status
 //
 // nType = NWNX_APPEARANCE_TYPE_HAIR_COLOR
 // nType = NWNX_APPEARANCE_TYPE_SKIN_COLOR
 // nValue = 0-175 or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_PHENOTYPE
 // nValue = PHENOTYPE_* or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_HEAD_TYPE
 // nValue = 0-? or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_SOUNDSET
 // nValue = See soundset.2da or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_TAIL_TYPE
 // nValue = CREATURE_WING_TYPE_* or see wingmodel.2da, -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_WING_TYPE
 // nValue = CREATURE_TAIL_TYPE_* or see tailmodel.2da, -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_FOOTSTEP_SOUND
 // nValue = 0-17 or see footstepsounds.2da, -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_PORTRAIT
 // nValue = See portraits.2da, -1 to remove
 // NOTE: Does not change the Examine Window portrait
 public static void SetOverride(uint oPlayer, uint oCreature, OverrideType nType, int nValue)
 {
     Internal.NativeFunctions.nwnxSetFunction(PluginName, "SetOverride");
     Internal.NativeFunctions.nwnxPushInt(nValue);
     Internal.NativeFunctions.nwnxPushInt((int)nType);
     Internal.NativeFunctions.nwnxPushObject(oCreature);
     Internal.NativeFunctions.nwnxPushObject(oPlayer);
     Internal.NativeFunctions.nwnxCallFunction();
 }
Exemplo n.º 12
0
 // Override oCreature's nType to nValue for oPlayer
 // - oCreature can be a PC
 //
 // nType = NWNX_APPEARANCE_TYPE_APPEARANCE
 // nValue = APPEARANCE_TYPE_* or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_GENDER
 // nValue = GENDER_* or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_HITPOINTS
 // nValue = 0-GetMaxHitPoints(oCreature) or -1 to remove
 // NOTE: This is visual only. Does not change the Examine Window health status
 //
 // nType = NWNX_APPEARANCE_TYPE_HAIR_COLOR
 // nType = NWNX_APPEARANCE_TYPE_SKIN_COLOR
 // nValue = 0-175 or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_PHENOTYPE
 // nValue = PHENOTYPE_* or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_HEAD_TYPE
 // nValue = 0-? or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_SOUNDSET
 // nValue = See soundset.2da or -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_TAIL_TYPE
 // nValue = CREATURE_WING_TYPE_* or see wingmodel.2da, -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_WING_TYPE
 // nValue = CREATURE_TAIL_TYPE_* or see tailmodel.2da, -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_FOOTSTEP_SOUND
 // nValue = 0-17 or see footstepsounds.2da, -1 to remove
 //
 // nType = NWNX_APPEARANCE_TYPE_PORTRAIT
 // nValue = See portraits.2da, -1 to remove
 // NOTE: Does not change the Examine Window portrait
 public static void SetOverride(uint player, uint creature, OverrideType type, int value)
 {
     Internal.NativeFunctions.nwnxSetFunction(PLUGIN_NAME, "SetOverride");
     Internal.NativeFunctions.nwnxPushInt(value);
     Internal.NativeFunctions.nwnxPushInt((int)type);
     Internal.NativeFunctions.nwnxPushObject(creature);
     Internal.NativeFunctions.nwnxPushObject(player);
     Internal.NativeFunctions.nwnxCallFunction();
 }
Exemplo n.º 13
0
 // Get oCreature's nValue of nType for oPlayer
 // - oCreature can be a PC
 // Returns -1 when not set
 public static int GetOverride(uint player, uint creature, OverrideType type)
 {
     Internal.NativeFunctions.nwnxSetFunction(PLUGIN_NAME, "GetOverride");
     Internal.NativeFunctions.nwnxPushInt((int)type);
     Internal.NativeFunctions.nwnxPushObject(creature);
     Internal.NativeFunctions.nwnxPushObject(player);
     Internal.NativeFunctions.nwnxCallFunction();
     return(Internal.NativeFunctions.nwnxPopInt());
 }
Exemplo n.º 14
0
 public void OverrideContent(bool isOverridden)
 {
     if (CanOverride)
     {
         OverrideChanging?.Invoke(this, EventArgs.Empty);
         contentOverride = isOverridden ? OverrideType.New : OverrideType.Base;
         OverrideChanged?.Invoke(this, EventArgs.Empty);
     }
 }
Exemplo n.º 15
0
 // Get oCreature's nValue of nType for oPlayer
 // - oCreature can be a PC
 // Returns -1 when not set
 public static int GetOverride(uint oPlayer, uint oCreature, OverrideType nType)
 {
     Internal.NativeFunctions.nwnxSetFunction(PluginName, "GetOverride");
     Internal.NativeFunctions.nwnxPushInt((int)nType);
     Internal.NativeFunctions.nwnxPushObject(oCreature);
     Internal.NativeFunctions.nwnxPushObject(oPlayer);
     Internal.NativeFunctions.nwnxCallFunction();
     return(Internal.NativeFunctions.nwnxPopInt());
 }
Exemplo n.º 16
0
 protected PermissionOverride(ChannelId channelId, Permission permission, OverrideType type)
 {
     if (!_validPermissions.Contains(permission))
     {
         throw new InvalidPermissionOverride(permission.Name);
     }
     ChannelId  = channelId;
     Permission = permission;
     Type       = type;
 }
Exemplo n.º 17
0
 private static void SetOverride(OverrideType overrideType, ItemId id, [NotNull] Dictionary <ItemId, OverrideType> dictionary)
 {
     if (overrideType == OverrideType.Base)
     {
         dictionary.Remove(id);
     }
     else
     {
         dictionary[id] = overrideType;
     }
 }
Exemplo n.º 18
0
        /// <summary>
        /// Create the configuration loader
        /// </summary>
        /// <param name="machineNameFinder">abstracts out the accessing of what the machine name is</param>
        /// <param name="appSettings">abstacts out the process of accessing app settings</param>
        /// <param name="globalSettingsName">the name of the section within the configSectionName that will act as the base global settings.  This is defaulted to global</param>
        /// <param name="overrideType">The type of override wanted.  By default it will use chaining, which will try to find first valid type. Env - Appsetting - Machine name.</param>
        public ConfigurationLoader(IMachineNameFinder machineNameFinder, IAppSettingsLoader appSettings, string globalSettingsName = "global", OverrideType overrideType = OverrideType.Chain)
        {
            _config       = new Config();
            _overrideType = overrideType;

            if (!_config.SectionNames.Contains(globalSettingsName))
            {
                throw new ArgumentOutOfRangeException("globalSettingsName", "No global section found");
            }

            _globalSection     = _config.GetSection(globalSettingsName);
            _machineNameFinder = machineNameFinder;
            _appSettings       = appSettings;
        }
Exemplo n.º 19
0
        /// <summary>
        /// Sets the override type for the specified member.
        /// </summary>
        /// <param name="key">The member name to setup an override</param>
        /// <param name="type">Type of the override</param>
        public void SetOverride(string key, OverrideType type)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            YamlNode previousMemberKey   = null;
            YamlNode previousMemberValue = null;

            if (keyMapping == null)
            {
                keyMapping = new Dictionary <string, string>();
            }
            else
            {
                string previousMemberName;
                if (keyMapping.TryGetValue(key, out previousMemberName))
                {
                    previousMemberKey = new YamlScalarNode(previousMemberName);
                    node.Children.TryGetValue(previousMemberKey, out previousMemberValue);
                }
                keyMapping.Remove(key);
            }

            if (overrides == null)
            {
                overrides = new Dictionary <string, OverrideType>();
            }
            else
            {
                overrides.Remove(key);
            }

            // New member name
            var newMemberName = type == OverrideType.Base
                ? key
                : $"{key}{type.ToText()}";

            keyMapping[key] = newMemberName;
            overrides[key]  = type;

            // Remap the original YAML node with the override type
            if (previousMemberKey != null)
            {
                int index = node.Children.IndexOf(previousMemberKey);
                node.Children.RemoveAt(index);
                node.Children.Insert(index, new YamlScalarNode(newMemberName), previousMemberValue);
            }
        }
Exemplo n.º 20
0
    /// <summary>
    /// 버프 생성 시 버프가 같은 종류일 때 상존할 수 없는 경우 덮어써야하는 데,
    /// 이 경우 어떤 식으로 덮어 쓸 지에 대해서 이야기하고 있다.
    /// </summary>
    /// <param name="owner">버프 소유주</param>
    /// <param name="overrideType">어떤 식으로 버프를 덮어쓸 지 그 타입에 대해서 서술하고 있다.</param>
    /// <returns>이 객체가 이 매서드에 의해 유효성을 잃었는 지의 여부를 돌려준다.</returns>
    /// <exception cref="ArgumentOutOfRangeException">구현되지 않은 부분에 대한 익셉션</exception>
    public bool OverrideValidCheck(Unit owner, OverrideType overrideType)
    {
        var duplicated = (Buff)null;

        // 같은 ParentType을 두고 있는 Buff를 가지고 있는 지 찾는다.
        foreach (var crowdControlCandidate in owner.CrowdControlGroup)
        {
            if (crowdControlCandidate == this)
            {
                duplicated = crowdControlCandidate;
            }
        }

        if (duplicated == null)
        {
            return(false);
        }

        // OverrideType 참조
        switch (overrideType)
        {
        case OverrideType.Recent:
            duplicated.OnTerminate();
            break;

        case OverrideType.Race:
            if (duplicated.Lifespan <= Lifespan)
            {
                Owner.CrowdControlGroup.Remove(duplicated);
            }
            else
            {
                return(true);
            }
            break;

        case OverrideType.Merge:
            duplicated.Lifespan += Lifespan;
            return(true);

        // 카운트는 실제로 사용될 수 있는 부분이 아니니 exception 처리
        case OverrideType.Count:
        default:
            throw new ArgumentOutOfRangeException(nameof(overrideType), overrideType, null);
        }

        return(false);
    }
Exemplo n.º 21
0
 public static string ToText(this OverrideType type)
 {
     if (type == OverrideType.New)
     {
         return(PostFixNewText);
     }
     if (type == OverrideType.Sealed)
     {
         return(PostFixSealedText);
     }
     if (type == (OverrideType.New | OverrideType.Sealed))
     {
         return(PostFixNewSealed);
     }
     return(string.Empty);
 }
Exemplo n.º 22
0
        public void AddOverriddenMember(MemberInfo memberInfo, OverrideType type)
        {
            switch (type)
            {
            case OverrideType.Target:
                _overriddenTargetMembers.Add(memberInfo);
                break;

            case OverrideType.Mixin:
                _overriddenMixinMembers.Add(memberInfo);
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }
Exemplo n.º 23
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 13, Configuration.FieldSeparator),
                       Id,
                       ErrorCodeAndLocation,
                       ErrorLocation != null ? string.Join(Configuration.FieldRepeatSeparator, ErrorLocation.Select(x => x.ToDelimitedString())) : null,
                       Hl7ErrorCode?.ToDelimitedString(),
                       Severity,
                       ApplicationErrorCode?.ToDelimitedString(),
                       ApplicationErrorParameter != null ? string.Join(Configuration.FieldRepeatSeparator, ApplicationErrorParameter) : null,
                       DiagnosticInformation?.ToDelimitedString(),
                       UserMessage?.ToDelimitedString(),
                       InformPersonIndicator != null ? string.Join(Configuration.FieldRepeatSeparator, InformPersonIndicator.Select(x => x.ToDelimitedString())) : null,
                       OverrideType?.ToDelimitedString(),
                       OverrideReasonCode != null ? string.Join(Configuration.FieldRepeatSeparator, OverrideReasonCode.Select(x => x.ToDelimitedString())) : null,
                       HelpDeskContactPoint != null ? string.Join(Configuration.FieldRepeatSeparator, HelpDeskContactPoint.Select(x => x.ToDelimitedString())) : null
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Exemplo n.º 24
0
        /// <summary>
        /// 读取函数内容
        /// </summary>
        /// <param name="picnode">代码图节点</param>
        /// <param name="pic">代码图(类)</param>
        public static void ReadFunction(XmlNode functionnode, PicTabPage pic)
        {
            XmlElement functionElement = (XmlElement)functionnode;
            string     Title           = functionElement.GetAttribute("Title");
            int        ID = int.Parse(functionElement.GetAttribute("ID"));

            XObject.OpenType myOpenType     = XObject.OpenTypeMapping(functionElement.GetAttribute("OpenType"));
            OverrideType     myOverrideType = XObject.OverrideTypeMapping(functionElement.GetAttribute("OverrideType"));

            PicFunctionTabPage functionpage = pic.LoadFunctionPage(Title, ID, myOpenType, myOverrideType);

            ///查找CodeBox节点
            foreach (XmlNode node in functionnode.SelectNodes("CodeBox"))
            {
                DataWriteFunction.ReadCodeBoxObject(node, functionpage);
            }
            ///查找BezierLine节点
            foreach (XmlNode node in functionnode.SelectNodes("BezierLine"))
            {
                DataWriteFunction.ReadBezierLine(node, functionpage);
            }
        }
        public static bool CompatibilityState(OverrideType type, Addon addon, string oldVersion = "") //requires -1 instead of *
        {
            switch (type)
            {
            case OverrideType.name:
            {
                return(addon.IsForcedCompatibleByName);
            }

            case OverrideType.version:
            {
                if (oldVersion != "")
                {
                    oldVersion = oldVersion.Replace("*", "-1");
                    bool b = (from d in Configuration.CompatibleVersions
                              where oldVersion == d.Key
                              where d.Value.compatWithVersion.Contains(AddonInfo.ActualKspVersion)
                              select d).Any();
                    return(b);
                }
                return(addon.IsForcedCompatibleByVersion);
            }

            case OverrideType.ignore:
            {
                return(Configuration.modsIgnoreOverride.Contains(addon.Name));
            }

            case OverrideType.locked:
            {
                return(addon.IsLockedByCreator);
            }

            default:
            {
                return(false);
            }
            }
        }
Exemplo n.º 26
0
        internal static string TrimAndParseOverride(string name, out OverrideType[] overrideTypes)
        {
            var split = name.Split('~');

            overrideTypes = new OverrideType[split.Length];
            int i           = 0;
            var trimmedName = string.Empty;

            foreach (var namePart in split)
            {
                var realName = namePart.Trim(OverridePostfixes.PostFixSealed, OverridePostfixes.PostFixNew);

                var overrideType = OverrideType.Base;
                if (realName.Length != namePart.Length)
                {
                    if (namePart.Contains(OverridePostfixes.PostFixNewSealed) || namePart.EndsWith(OverridePostfixes.PostFixNewSealedAlt))
                    {
                        overrideType = OverrideType.New | OverrideType.Sealed;
                    }
                    else if (namePart.EndsWith(OverridePostfixes.PostFixNew))
                    {
                        overrideType = OverrideType.New;
                    }
                    else if (namePart.EndsWith(OverridePostfixes.PostFixSealed))
                    {
                        overrideType = OverrideType.Sealed;
                    }
                }
                overrideTypes[i] = overrideType;
                if (i > 0)
                {
                    trimmedName += '~';
                }
                trimmedName += realName;
                ++i;
            }
            return(trimmedName);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Gets the value from the specified root object following this instance path.
        /// </summary>
        /// <param name="rootObject">The root object.</param>
        /// <param name="value">The returned value.</param>
        /// <param name="overrideType">Type of the override.</param>
        /// <returns><c>true</c> if evaluation of the path succeeded and the value is valid, <c>false</c> otherwise.</returns>
        /// <exception cref="System.ArgumentNullException">rootObject</exception>
        public bool TryGetValue(object rootObject, out object value, out OverrideType overrideType)
        {
            if (rootObject == null)
            {
                throw new ArgumentNullException("rootObject");
            }
            if (items.Count == 0)
            {
                throw new InvalidOperationException("No items pushed via Push methods");
            }

            value        = null;
            overrideType = OverrideType.Base;
            try
            {
                object nextObject = rootObject;

                var lastItem         = items[items.Count - 1];
                var memberDescriptor = lastItem.MemberDescriptor;

                for (int i = 0; i < items.Count - 1; i++)
                {
                    var item = items[i];
                    nextObject = item.GetValue(nextObject);
                }

                overrideType = nextObject.GetOverride(memberDescriptor);
                value        = lastItem.GetValue(nextObject);
            }
            catch (Exception)
            {
                // If an exception occurred, we cannot resolve this member path to a valid property/field
                return(false);
            }
            return(true);
        }
        public static RaycastInfo OV_raycast(Ray ray, float range, int mask, Player ignorePlayer)
        {
            OverrideType ovtype = OV_DamageTool.OVType;

            if (ovtype == OverrideType.Extended)
            {
                RaycastInfo raycastInfo = RaycastUtilities.GenerateOriginalRaycast(ray, Mathf.Max(20f, range), mask, ignorePlayer);
                float       num         = MiscOptions.ExtendRangeBypass ? range : Mathf.Max(5.5f, range);
                raycastInfo.point = ((Vector3.Distance(raycastInfo.point, ray.origin) > num) ? (ray.direction * num + ray.origin) : raycastInfo.point);
                return(raycastInfo);
            }
            if (ovtype == OverrideType.SilentAimMelee)
            {
                RaycastInfo raycastInfo2;
                if (!RaycastUtilities.GenerateRaycast(out raycastInfo2) && !MiscOptions.ExtendMeleeRange)
                {
                    raycastInfo2 = RaycastUtilities.GenerateOriginalRaycast(ray, range, mask, ignorePlayer);
                }
                float num2 = MiscOptions.ExtendRangeBypass ? range : Mathf.Max(5.5f, range);
                raycastInfo2.point = ((Vector3.Distance(raycastInfo2.point, ray.origin) > num2) ? (ray.direction * num2 + ray.origin) : raycastInfo2.point);
                return(raycastInfo2);
            }
            return(RaycastUtilities.GenerateOriginalRaycast(ray, range, mask, ignorePlayer));
        }
Exemplo n.º 29
0
 /// <summary>
 /// Sets the override for the specified member.
 /// </summary>
 /// <param name="instance">The instance.</param>
 /// <param name="memberDescriptor">The member descriptor.</param>
 /// <param name="overrideType">Type of the override.</param>
 /// <exception cref="System.ArgumentNullException">
 /// instance
 /// or
 /// memberDescriptor
 /// </exception>
 public static void SetOverride(this object instance, IMemberDescriptor memberDescriptor, OverrideType overrideType)
 {
     if (instance == null) throw new ArgumentNullException(nameof(instance));
     if (memberDescriptor == null) throw new ArgumentNullException(nameof(memberDescriptor));
     instance.SetDynamicProperty(memberDescriptor, OverrideKey, overrideType);
 }
Exemplo n.º 30
0
        /// <summary>
        /// 从文件加载函数
        /// </summary>
        /// <param name="Title">函数名</param>
        /// <param name="ID">ID</param>
        public PicFunctionTabPage LoadFunctionPage(string Title, int ID, OpenType opentype, OverrideType overridetype)
        {
            foreach (PicFunctionTabPage fun in ListFunction)
            {
                if (fun.Title == Title)
                {
                    return(null);
                }
            }
            PicFunctionTabPage function = new PicFunctionTabPage(ID, this.CallBackFunction, Title);

            function.MyOpenType = opentype;
            function.MyOverride = overridetype;
            ListFunction.Add(function);
            return(function);
        }
Exemplo n.º 31
0
 public void AddOverriddenMember(MemberInfo memberInfo, OverrideType type)
 {
     switch(type)
       {
     case OverrideType.Target:
       _overriddenTargetMembers.Add(memberInfo);
       break;
     case OverrideType.Mixin:
       _overriddenMixinMembers.Add(memberInfo);
       break;
     default:
       throw new ArgumentOutOfRangeException("type");
       }
 }
        internal static string TrimAndParseOverride(string name, out OverrideType[] overrideTypes)
        {
            var split = name.Split('~');

            overrideTypes = new OverrideType[split.Length];
            int i = 0;
            var trimmedName = string.Empty;
            foreach (var namePart in split)
            {
                var realName = namePart.Trim(OverridePostfixes.PostFixSealed, OverridePostfixes.PostFixNew);

                var overrideType = OverrideType.Base;
                if (realName.Length != namePart.Length)
                {
                    if (namePart.Contains(OverridePostfixes.PostFixNewSealed) || namePart.EndsWith(OverridePostfixes.PostFixNewSealedAlt))
                    {
                        overrideType = OverrideType.New | OverrideType.Sealed;
                    }
                    else if (namePart.EndsWith(OverridePostfixes.PostFixNew))
                    {
                        overrideType = OverrideType.New;
                    }
                    else if (namePart.EndsWith(OverridePostfixes.PostFixSealed))
                    {
                        overrideType = OverrideType.Sealed;
                    }
                }
                overrideTypes[i] = overrideType;
                if (i > 0)
                    trimmedName += '~';
                trimmedName += realName;
                ++i;
            }
            return trimmedName;
        }
Exemplo n.º 33
0
 /// <summary>
 /// Sets the override for the specified member.
 /// </summary>
 /// <param name="instance">The instance.</param>
 /// <param name="memberDescriptor">The member descriptor.</param>
 /// <param name="overrideType">Type of the override.</param>
 /// <exception cref="System.ArgumentNullException">
 /// instance
 /// or
 /// memberDescriptor
 /// </exception>
 public static void SetOverride(this object instance, IMemberDescriptor memberDescriptor, OverrideType overrideType)
 {
     if (instance == null) throw new ArgumentNullException("instance");
     if (memberDescriptor == null) throw new ArgumentNullException("memberDescriptor");
     instance.SetDynamicProperty(memberDescriptor, OverrideKey, overrideType);
 }
Exemplo n.º 34
0
 public Override(OverrideType type)
 {
     this.type = type;
 }
Exemplo n.º 35
0
        /// <summary>
        /// Sets the override type for the specified member.
        /// </summary>
        /// <param name="key">The member name to setup an override</param>
        /// <param name="type">Type of the override</param>
        public void SetOverride(string key, OverrideType type)
        {
            if (key == null) throw new ArgumentNullException(nameof(key));

            YamlNode previousMemberKey = null;
            YamlNode previousMemberValue = null;

            if (keyMapping == null)
            {
                keyMapping = new Dictionary<string, string>();
            }
            else
            {
                string previousMemberName;
                if (keyMapping.TryGetValue(key, out previousMemberName))
                {
                    previousMemberKey = new YamlScalarNode(previousMemberName);
                    node.Children.TryGetValue(previousMemberKey, out previousMemberValue);
                }
                keyMapping.Remove(key);
            }

            if (overrides == null)
            {
                overrides = new Dictionary<string, OverrideType>();
            }
            else
            {
                overrides.Remove(key);
            }

            // New member name
            var newMemberName = type == OverrideType.Base
                ? key
                : $"{key}{type.ToText()}";
            
            keyMapping[key] = newMemberName;
            overrides[key] = type;

            // Remap the original YAML node with the override type
            if (previousMemberKey != null)
            {
                int index = node.Children.IndexOf(previousMemberKey);
                node.Children.RemoveAt(index);
                node.Children.Insert(index, new YamlScalarNode(newMemberName), previousMemberValue);
            }
        }
Exemplo n.º 36
0
 /// <summary>
 /// Determines whether the specified type is new.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <returns><c>true</c> if the specified type is new; otherwise, <c>false</c>.</returns>
 public static bool IsNew(this OverrideType type)
 {
     return((type & OverrideType.New) != 0);
 }
Exemplo n.º 37
0
 private static void SetOverride(OverrideType overrideType, ItemId id, Dictionary<ItemId, OverrideType> dictionary)
 {
     if (overrideType == OverrideType.Base)
     {
         dictionary.Remove(id);
     }
     else
     {
         dictionary[id] = overrideType;
     }
 }
Exemplo n.º 38
0
 internal void SetKeyOverride(OverrideType overrideType, Index index)
 {
     if (CanOverride)
     {
         var id = IndexToId(index);
         SetOverride(overrideType, id, keyOverrides);
     }
 }
Exemplo n.º 39
0
 internal void SetContentOverride(OverrideType overrideType)
 {
     if (CanOverride)
     {
         contentOverride = overrideType;
     }
 }