コード例 #1
0
        public override IEnumerable <ValidationMessage> Validate(IClassDefinition classDefinition)
        {
            if (classDefinition == null)
            {
                throw new ArgumentNullException(nameof(classDefinition));
            }

            if (classDefinition.Constructors.Count > 1)
            {
                yield return(new ValidationMessage
                {
                    LogLevel = LogLevel.Error,
                    Message = "Class definitions on typescript only have one constructor"
                });
            }

            foreach (var method in classDefinition.Methods)
            {
                if (classDefinition.Methods.Where(m => m.Name == method.Name).Count() > 1)
                {
                    yield return(new ValidationMessage
                    {
                        LogLevel = LogLevel.Error,
                        Message = string.Format("There is more than one method with name '{0}'", method.Name)
                    });
                }
            }

            var validations = base.Validate(classDefinition);

            foreach (var item in validations)
            {
                yield return(item);
            }
        }
コード例 #2
0
ファイル: Stamina.cs プロジェクト: VArsovski/D4STSimulator2
        public decimal CalculateRegen(IClassDefinition classInfo)
        {
            // var life = CalculateAmount(level, classType);
            var totalRegen = Convert.ToDouble(BasicRegen + BonusRegen);

            return(DecimalHelper.RoundToDecimals(totalRegen * Convert.ToDouble(1 + BonusRegenPercentage), 2));
        }
コード例 #3
0
 public IFieldDefinition GetFieldDefinition(IClassDefinition classDef, string name)
 {
     var fd = classDef.GetField(name);
     if (fd == null)
     {
         var fieldNames = name.Split('.');
         if (fieldNames.Length > 1)
         {
             var currentClassDef = classDef;
             for (var i = 0; i < fieldNames.Length; i++)
             {
                 name = fieldNames[i];
                 fd = currentClassDef.GetField(name);
                 if (i == fieldNames.Length - 1)
                 {
                     break;
                 }
                 if (fd == null)
                 {
                     throw new ArgumentException("Unknown field: " + name);
                 }
                 currentClassDef = LookupClassDefinition(fd.GetFactoryId(), fd.GetClassId(),
                     currentClassDef.GetVersion());
                 if (currentClassDef == null)
                 {
                     throw new ArgumentException("Not a registered Portable field: " + fd);
                 }
             }
         }
     }
     return fd;
 }
コード例 #4
0
        private static ISkillDamageStat CalculateSkillPowerPrimary(IClassDefinition classInfo)
        {
            var skillDamageStat = new DamageSkillStat(1, 1, 1);

            var fibonacciLine = new List <int> {
                1, 2, 3, 5, 8, 13, 21, 34, 55
            };
            var squareRootLine = new List <int> {
                1, 4, 9, 16, 25, 36, 49
            };

            var from       = fibonacciLine.IndexOf(fibonacciLine.FirstOrDefault(c => c > classInfo.Level));
            var skillBonus = Convert.ToInt32(Math.Sqrt(squareRootLine.IndexOf(squareRootLine.FirstOrDefault(c => c > classInfo.Level))));

            if (classInfo.ClassType == ClassTypeEnum.Sorceress)
            {
                skillBonus += Convert.ToInt32(Math.Sqrt(1 + skillBonus));
            }

            skillDamageStat.From  = from;
            skillDamageStat.To    = from + skillBonus;
            skillDamageStat.Level = classInfo.Level;

            return(skillDamageStat);
        }
コード例 #5
0
 private void RegisterClassDefinition(IClassDefinition cd, IDictionary <int, IClassDefinition> classDefMap,
                                      bool checkClassDefErrors)
 {
     for (var i = 0; i < cd.GetFieldCount(); i++)
     {
         var fd = cd.GetField(i);
         if (fd.GetFieldType() == FieldType.Portable || fd.GetFieldType() == FieldType.PortableArray)
         {
             var classId = fd.GetClassId();
             IClassDefinition nestedCd;
             classDefMap.TryGetValue(classId, out nestedCd);
             if (nestedCd != null)
             {
                 RegisterClassDefinition(nestedCd, classDefMap, checkClassDefErrors);
                 _portableContext.RegisterClassDefinition(nestedCd);
             }
             else
             {
                 if (checkClassDefErrors)
                 {
                     throw new HazelcastSerializationException(
                               "Could not find registered ClassDefinition for class-id: " + classId);
                 }
             }
         }
     }
     _portableContext.RegisterClassDefinition(cd);
 }
コード例 #6
0
            internal IClassDefinition Register(IClassDefinition cd)
            {
                if (cd == null)
                {
                    return(null);
                }
                if (cd.GetFactoryId() != _factoryId)
                {
                    throw new HazelcastSerializationException("Invalid factory-id! " + _factoryId + " -> " + cd);
                }
                if (cd is ClassDefinition)
                {
                    var cdImpl = (ClassDefinition)cd;
                    cdImpl.SetVersionIfNotSet(_portableContext.GetVersion());
                }
                var versionedClassId = Bits.CombineToLong(cd.GetClassId(), cd.GetVersion());
                var currentCd        = _versionedDefinitions.GetOrAdd(versionedClassId, cd);

                if (Equals(currentCd, cd))
                {
                    return(cd);
                }
                if (currentCd is ClassDefinition)
                {
                    if (!currentCd.Equals(cd))
                    {
                        throw new HazelcastSerializationException(
                                  "Incompatible class-definitions with same class-id: " + cd + " VS " + currentCd);
                    }
                    return(currentCd);
                }
                _versionedDefinitions.AddOrUpdate(versionedClassId, cd, (key, oldValue) => cd);
                return(cd);
            }
コード例 #7
0
        public IFieldDefinition GetFieldDefinition(IClassDefinition classDef, string name)
        {
            var fd = classDef.GetField(name);

            if (fd == null)
            {
                var fieldNames = name.Split('.');
                if (fieldNames.Length > 1)
                {
                    var currentClassDef = classDef;
                    for (var i = 0; i < fieldNames.Length; i++)
                    {
                        name = fieldNames[i];
                        fd   = currentClassDef.GetField(name);
                        if (i == fieldNames.Length - 1)
                        {
                            break;
                        }
                        if (fd == null)
                        {
                            throw new ArgumentException("Unknown field: " + name);
                        }
                        currentClassDef = LookupClassDefinition(fd.GetFactoryId(), fd.GetClassId(),
                                                                currentClassDef.GetVersion());
                        if (currentClassDef == null)
                        {
                            throw new ArgumentException("Not a registered Portable field: " + fd);
                        }
                    }
                }
            }
            return(fd);
        }
コード例 #8
0
        private DefaultPortableReader CreateReader(IBufferObjectDataInput input, int factoryId, int classId, int version, int portableVersion)
        {
            int effectiveVersion = version;

            if (version < 0)
            {
                effectiveVersion = context.GetVersion();
            }
            IClassDefinition cd = context.LookupClassDefinition(factoryId, classId, effectiveVersion);

            if (cd == null)
            {
                int begin = input.Position();
                cd = context.ReadClassDefinition(input, factoryId, classId, effectiveVersion);
                input.Position(begin);
            }
            DefaultPortableReader reader;

            if (portableVersion == effectiveVersion)
            {
                reader = new DefaultPortableReader(this, input, cd);
            }
            else
            {
                reader = new MorphingPortableReader(this, input, cd);
            }
            return(reader);
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="classDefinition"></param>
        /// <returns></returns>
        public virtual ValidationResult Validate(IClassDefinition classDefinition)
        {
            if (classDefinition == null)
            {
                throw new ArgumentNullException(nameof(classDefinition));
            }

            var result = new ValidationResult();

            if (string.IsNullOrEmpty(classDefinition.Name))
            {
                result.ValidationMessages.Add(new ValidationMessage(LogLevel.Error, "There isn't name for class definition"));
            }

            foreach (var field in classDefinition.Fields)
            {
                if (classDefinition.Fields.Where(p => p.Name == field.Name).Count() > 1)
                {
                    result.ValidationMessages.Add(new ValidationMessage(LogLevel.Error, string.Format("There is more than one field with name '{0}'", field.Name)));
                }
            }

            foreach (var property in classDefinition.Properties)
            {
                if (classDefinition.Properties.Where(p => p.Name == property.Name).Count() > 1)
                {
                    result.ValidationMessages.Add(new ValidationMessage(LogLevel.Error, string.Format("There is more than one property with name '{0}'", property.Name)));
                }
            }

            return(result);
        }
コード例 #10
0
            internal IClassDefinition Lookup(int classId, int version)
            {
                var versionedClassId = Bits.CombineToLong(classId, version);
                IClassDefinition cd  = null;

                _versionedDefinitions.TryGetValue(versionedClassId, out cd);
                return(cd);
            }
コード例 #11
0
        public static DamageSkillStat CalculateHitData(IClassDefinition classInfo)
        {
            var data = CalculateHitDamageLevels(classInfo).FirstOrDefault(x => x.Level == classInfo.Level);

            var selected = new DamageSkillStat(data.From, data.To, 0, 0, 0, 0);

            selected.Level = classInfo.Level;
            return(selected);
        }
コード例 #12
0
        internal FieldDefinition(IFieldSymbol symbol, IClassDefinition referencedClass)
        {
            Contract.Requires(symbol != null);
            Contract.Requires(referencedClass != null);

            this.Symbol          = symbol;
            this.Sort            = References.Sort;
            this.ReferencedClass = referencedClass;
        }
コード例 #13
0
 public ClassDefinition(IClassDefinition classDefinition)
 {
     this.classDefinition  = classDefinition;
     this.ClassType        = classDefinition.ClassType;
     this.ClassDescription = classDefinition.ClassDescription;
     this.Level            = classDefinition.Level;
     this.AngelicPower     = classDefinition.AngelicPower;
     this.DemonicPower     = classDefinition.DemonicPower;
     this.AncestralPower   = classDefinition.AncestralPower;
 }
コード例 #14
0
 /// <summary>
 /// Adds a <see cref="IPortable"/> class definition to be registered
 /// </summary>
 /// <param name="classDefinition"><see cref="IPortable"/> class definition</param>
 /// <returns>configured <see cref="SerializationConfig"/> for chaining</returns>
 public virtual SerializationConfig AddClassDefinition(IClassDefinition classDefinition)
 {
     if (GetClassDefinitions().Contains(classDefinition))
     {
         throw new ArgumentException("IClassDefinition for class-id[" + classDefinition.GetClassId() +
                                     "] already exists!");
     }
     GetClassDefinitions().Add(classDefinition);
     return(this);
 }
コード例 #15
0
 public virtual SerializationConfig AddClassDefinition(IClassDefinition classDefinition)
 {
     if (GetClassDefinitions().Contains(classDefinition))
     {
         throw new ArgumentException("IClassDefinition for class-id[" + classDefinition.GetClassId() +
                                     "] already exists!");
     }
     GetClassDefinitions().Add(classDefinition);
     return this;
 }
コード例 #16
0
        /// <exception cref="System.IO.IOException"/>
        internal void WriteInternal(IBufferObjectDataOutput output, IPortable p)
        {
            IClassDefinition cd = context.LookupOrRegisterClassDefinition(p);

            output.WriteInt(cd.GetVersion());
            DefaultPortableWriter writer = new DefaultPortableWriter(this, output, cd);

            p.WritePortable(writer);
            writer.End();
        }
コード例 #17
0
        public DamagePerHit(IClassDefinition classInfo)
        {
            var data = SpellCalculator.CalculateHitData(classInfo);

            this.MinValue = data.From;
            this.MaxValue = data.To;

            // TODO: Return IsMax when Maxxed !!!
            this.BonusMinValue = Math.Min(60, Convert.ToInt32(classInfo.AncestralPower / 2));
            this.BonusMaxValue = Math.Min(120, classInfo.AncestralPower);
        }
 public ClassDefinitionBuilder AddPortableField(string fieldName, IClassDefinition def)
 {
     Check();
     if (def.GetClassId() == 0)
     {
         throw new ArgumentException("Portable class id cannot be zero!");
     }
     _fieldDefinitions.Add(new FieldDefinition(_index++, fieldName, FieldType.Portable, def.GetFactoryId(),
                                               def.GetClassId()));
     return(this);
 }
コード例 #19
0
        public SelfEmpowerHitProc CalculateProcAmount(IClassDefinition classInfo)
        {
            var baseProcRate  = DecimalHelper.RoundToDecimals((classInfo.ClassType == Enums.ClassTypeEnum.Barbarian ? 10 : 6) / 100, 3);
            var bonusProcRate = DecimalHelper.RoundToDecimals(0.66 * classInfo.DemonicPower * (classInfo.ClassType == Enums.ClassTypeEnum.Barbarian ? 0.6 : 0.5), 3);
            var procAmount    = DecimalHelper.RoundToDecimals(Convert.ToDouble(baseProcRate + bonusProcRate), 2);

            var resourceReturnProc = new SelfEmpowerHitProc {
                ProcPercentage = 1, ProcAmount = procAmount, Duration = 0
            };

            return(resourceReturnProc);
        }
コード例 #20
0
        public static List <ISkillDamageStat> CalculateHitDamageLevels(IClassDefinition classInfo)
        {
            var sampleData = new List <ISkillDamageStat>();

            for (int lvl = 1; lvl < 20; lvl++)
            {
                var data = CalculateSkillPowerPrimary(classInfo);
                sampleData.Add(data);
            }

            return(sampleData);
        }
コード例 #21
0
        /// <exception cref="System.IO.IOException"></exception>
        public void WriteNullPortable(string fieldName, int factoryId, int classId)
        {
            IClassDefinition nestedClassDef = context.LookupClassDefinition(factoryId, classId
                                                                            , context.GetVersion());

            if (nestedClassDef == null)
            {
                throw new HazelcastSerializationException("Cannot write null portable without explicitly "
                                                          + "registering class definition!");
            }
            builder.AddPortableField(fieldName, nestedClassDef);
        }
コード例 #22
0
        /// <exception cref="System.IO.IOException"></exception>
        public void WritePortable(string fieldName, IPortable portable)
        {
            if (portable == null)
            {
                throw new HazelcastSerializationException("Cannot write null portable without explicitly "
                                                          + "registering class definition!");
            }
            int version = PortableVersionHelper.GetVersion(portable, context.GetVersion());
            IClassDefinition nestedClassDef = CreateNestedClassDef(portable, new ClassDefinitionBuilder
                                                                       (portable.GetFactoryId(), portable.GetClassId(), version));

            builder.AddPortableField(fieldName, nestedClassDef);
        }
コード例 #23
0
        public Life(IClassDefinition classInfo, CharacterClass classData)
        {
            var baseAmt = (classInfo.ClassType == ClassTypeEnum.Sorceress ? 45 : 55);

            BasicAmount = classData.HP + classInfo.Level * 1;
            BonusAmount = classInfo.AngelicPower * 4;
            TotalAmount = CalculateAmount(classInfo);
            var regenCoeff = DecimalHelper.RoundToDecimals(Math.Pow(Convert.ToDouble(1.05), classInfo.Level / 2), 3);

            BasicRegen = Math.Round(0.024m * classData.HPRegen, 3);
            var ratio = Math.Round((decimal)BonusAmount / classData.HP, 3);

            BonusRegen = Math.Round(regenCoeff * ratio, 2);
            TotalRegen = CalculateRegen(classInfo);
        }
コード例 #24
0
 public ClassDefinitionBuilder AddPortableField(string fieldName, IClassDefinition def)
 {
     if (def == null)
     {
         throw new ArgumentNullException(nameof(def));
     }
     Check();
     if (def.ClassId == 0)
     {
         throw new ArgumentException("Portable class id cannot be zero!");
     }
     _fieldDefinitions.Add(new FieldDefinition(_index++, fieldName, FieldType.Portable, def.FactoryId,
                                               def.ClassId, def.Version));
     return(this);
 }
コード例 #25
0
 /// <exception cref="System.IO.IOException" />
 public DefaultPortableWriter(PortableSerializer serializer, IBufferObjectDataOutput @out, IClassDefinition cd)
 {
     this.serializer = serializer;
     this.@out = @out;
     this.cd = cd;
     writtenFields = new HashSet<string>(); //cd.GetFieldCount()
     begin = @out.Position();
     // room for final offset
     @out.WriteZeroBytes(4);
     @out.WriteInt(cd.GetFieldCount());
     offset = @out.Position();
     // one additional for raw data
     var fieldIndexesLength = (cd.GetFieldCount() + 1)*Bits.IntSizeInBytes;
     @out.WriteZeroBytes(fieldIndexesLength);
 }
コード例 #26
0
ファイル: Stamina.cs プロジェクト: VArsovski/D4STSimulator2
        public Stamina(IClassDefinition classInfo, CharacterClass classData)
        {
            var baseAmt = classInfo.ClassType == ClassTypeEnum.Druid ? 60 : classInfo.ClassType == ClassTypeEnum.Barbarian ? 50 : 35;

            BasicAmount = classData.Stamina + classInfo.Level * 1;
            BonusAmount = classInfo.AncestralPower * 4;
            TotalAmount = CalculateAmount(classInfo);
            var regenCoeff = DecimalHelper.RoundToDecimals(Math.Pow(Convert.ToDouble(1.05), classInfo.Level / 2), 3);
            var classCoeff = Math.Round((classInfo.ClassType == ClassTypeEnum.Druid ? 0.050m : 0.040m) * baseAmt, 3);

            BasicRegen = Math.Round(classCoeff * classData.StaminaRegen, 3);
            var ratio = Math.Round((decimal)BonusAmount / classData.Stamina, 3);

            BonusRegen = Math.Round(regenCoeff * ratio, 2);
            TotalRegen = CalculateRegen(classInfo);
        }
コード例 #27
0
        /// <exception cref="System.IO.IOException" />
        public DefaultPortableWriter(PortableSerializer serializer, IBufferObjectDataOutput @out, IClassDefinition cd)
        {
            this.serializer = serializer;
            this.@out       = @out;
            this.cd         = cd;
            writtenFields   = new HashSet <string>(); //cd.GetFieldCount()
            begin           = @out.Position();
            // room for final offset
            @out.WriteZeroBytes(4);
            @out.WriteInt(cd.GetFieldCount());
            offset = @out.Position();
            // one additional for raw data
            var fieldIndexesLength = (cd.GetFieldCount() + 1) * Bits.IntSizeInBytes;

            @out.WriteZeroBytes(fieldIndexesLength);
        }
コード例 #28
0
        /// <exception cref="System.IO.IOException" />
        public DefaultPortableWriter(PortableSerializer serializer, ObjectDataOutput @out, IClassDefinition cd)
        {
            _serializer    = serializer;
            _out           = @out;
            _cd            = cd;
            _writtenFields = new HashSet <string>(); //cd.GetFieldCount()
            _begin         = @out.Position;
            // room for final offset
            @out.WriteZeroBytes(4);
            @out.WriteInt(cd.GetFieldCount());
            _offset = @out.Position;
            // one additional for raw data
            var fieldIndexesLength = (cd.GetFieldCount() + 1) * BytesExtensions.SizeOfInt;

            @out.WriteZeroBytes(fieldIndexesLength);
        }
コード例 #29
0
        public virtual IEnumerable <ValidationMessage> Validate(IClassDefinition classDefinition)
        {
            if (classDefinition == null)
            {
                throw new ArgumentNullException(nameof(classDefinition));
            }

            if (string.IsNullOrEmpty(classDefinition.Name))
            {
                yield return(new ValidationMessage
                {
                    LogLevel = LogLevel.Error,
                    Message = "There isn't name for class definition"
                });
            }

            foreach (var field in classDefinition.Fields)
            {
                if (classDefinition.Fields.Where(p => p.Name == field.Name).Count() > 1)
                {
                    yield return(new ValidationMessage
                    {
                        LogLevel = LogLevel.Error,
                        Message = string.Format("There is more than one field with name '{0}'", field.Name)
                    });
                }
            }

            foreach (var property in classDefinition.Properties)
            {
                if (classDefinition.Properties.Where(p => p.Name == property.Name).Count() > 1)
                {
                    yield return(new ValidationMessage
                    {
                        LogLevel = LogLevel.Error,
                        Message = string.Format("There is more than one property with name '{0}'", property.Name)
                    });
                }
            }
        }
コード例 #30
0
ファイル: Definitions.cs プロジェクト: jhorv/Gibbed.Dunia
            public IMemberDefinition GetMemberDefinition(uint hash)
            {
                if (this.Members.ContainsKey(hash) == true)
                {
                    return(this.Members[hash]);
                }

                IClassDefinition current = this.Super;

                while (current != null)
                {
                    var member = current.GetMemberDefinition(hash);
                    if (member != null)
                    {
                        return(member);
                    }

                    current = current.Super;
                }

                return(null);
            }
コード例 #31
0
ファイル: Definitions.cs プロジェクト: jhorv/Gibbed.Dunia
            public IClassDefinition GetClassDefinition(uint hash)
            {
                if (this.Children.ContainsKey(hash) == true)
                {
                    return(this.Children[hash]);
                }

                IClassDefinition current = this.Super;

                while (current != null)
                {
                    var def = current.GetClassDefinition(hash);
                    if (def != null)
                    {
                        return(def);
                    }

                    current = current.Super;
                }

                return(this.Master.GetClassDefinition(hash));
            }
コード例 #32
0
        public SelfEmpowerHitProc CalculateProcAmount(IClassDefinition classInfo)
        {
            var baseProcPerc      = classInfo.ClassType == Enums.ClassTypeEnum.Barbarian ? 0.05m : 0.03m;
            var procPercAdditives = classInfo.AncestralPower * 0.55 + classInfo.AngelicPower * 0.11;
            var bonusMultiplier   = 0.45 * (Math.Pow(1.04, procPercAdditives));
            var bonusProcPerc     = DecimalHelper.RoundToDecimals(bonusMultiplier * procPercAdditives / 100, 3);

            var baseProcRate   = classInfo.ClassType == Enums.ClassTypeEnum.Barbarian ? 0.10m : 0.08m;
            var rateMultiplier = (Math.Pow(1.04, classInfo.DemonicPower / 4));
            var bonusProcRate  = DecimalHelper.RoundToDecimals((rateMultiplier * classInfo.AngelicPower * 1.25) / 4, 2);
            var basicDuration  = 1;
            var bonusDuration  = (classInfo.AngelicPower * 6.5) / 100;

            var procAmount = DecimalHelper.RoundToDecimals(Convert.ToDouble(baseProcRate + bonusProcRate), 2);
            var procPerc   = Math.Min(0.45m, DecimalHelper.RoundToDecimals(Convert.ToDouble((baseProcPerc + bonusProcPerc)), 2));

            var resourceReturnProc = new SelfEmpowerHitProc {
                ProcPercentage = procPerc * 100, ProcAmount = procAmount, Duration = DecimalHelper.RoundToDecimals(basicDuration * (1 + bonusDuration), 2)
            };

            return(resourceReturnProc);
        }
コード例 #33
0
        public LifestealHitProc CalculateProcAmount(IClassDefinition classInfo)
        {
            var mainDps = new DamagePerHit(classInfo);

            var baseProcPerc      = classInfo.ClassType == Enums.ClassTypeEnum.Barbarian ? 0.05m : 0.03m;
            var procPercAdditives = classInfo.AngelicPower * 0.125 + classInfo.AncestralPower * 0.55;
            var bonusMultiplier   = 0.35 * (Math.Pow(1.04, procPercAdditives));
            var bonusProcPerc     = DecimalHelper.RoundToDecimals(bonusMultiplier * procPercAdditives / 100, 3);
            var baseProcRate      = classInfo.ClassType == Enums.ClassTypeEnum.Barbarian ? 0.08m : 0.10m;
            var bonusProcRate     = 0.66m * DecimalHelper.RoundToDecimals((classInfo.AngelicPower * 1.4) / 100, 3);

            var average       = DecimalHelper.RoundToDecimals((mainDps.CalculateMinBase(classInfo) + mainDps.CalculateMaxBase(classInfo)) / 2, 3);
            var procAmountVal = DecimalHelper.RoundToDecimals(Convert.ToDouble(baseProcRate) + Convert.ToDouble(bonusProcRate), 3);
            var procAmount    = DecimalHelper.RoundToDecimals(Convert.ToDouble(average) * Convert.ToDouble(procAmountVal), 2);
            var procPerc      = Math.Min(0.45m, DecimalHelper.RoundToDecimals(Convert.ToDouble((baseProcPerc + bonusProcPerc)), 2));

            var lifestealProc = new LifestealHitProc {
                ProcPercentage = procPerc * 100, ProcAmount = procAmount, Duration = 0
            };

            return(lifestealProc);
        }
コード例 #34
0
 public ISerializationServiceBuilder AddClassDefinition(IClassDefinition cd)
 {
     classDefinitions.Add(cd);
     return this;
 }
コード例 #35
0
 public IClassDefinition RegisterClassDefinition(IClassDefinition cd)
 {
     return GetClassDefContext(cd.GetFactoryId()).Register(cd);
 }
コード例 #36
0
 internal IClassDefinition Register(IClassDefinition cd)
 {
     if (cd == null)
     {
         return null;
     }
     if (cd.GetFactoryId() != _factoryId)
     {
         throw new HazelcastSerializationException("Invalid factory-id! " + _factoryId + " -> " + cd);
     }
     if (cd is ClassDefinition)
     {
         var cdImpl = (ClassDefinition)cd;
         cdImpl.SetVersionIfNotSet(_portableContext.GetVersion());
     }
     var versionedClassId = Bits.CombineToLong(cd.GetClassId(), cd.GetVersion());
     var currentCd = _versionedDefinitions.GetOrAdd(versionedClassId, cd);
     if (Equals(currentCd, cd))
     {
         return cd;
     }
     if (currentCd is ClassDefinition)
     {
         if (!currentCd.Equals(cd))
         {
             throw new HazelcastSerializationException(
                 "Incompatible class-definitions with same class-id: " + cd + " VS " + currentCd);
         }
         return currentCd;
     }
     _versionedDefinitions.AddOrUpdate(versionedClassId, cd, (key, oldValue) => cd);
     return cd;
 }
コード例 #37
0
ファイル: sxDocClass.cs プロジェクト: moguidry/SirruXCloud
 public sxDocClass(IClassDefinition cd)
 {
     m_cd = cd;
 }
コード例 #38
0
 public ClassDefinitionBuilder AddPortableField(string fieldName, IClassDefinition def)
 {
     Check();
     if (def.GetClassId() == 0)
     {
         throw new ArgumentException("Portable class id cannot be zero!");
     }
     fieldDefinitions.Add(new FieldDefinition(index++, fieldName, FieldType.Portable, def.GetFactoryId(),
         def.GetClassId()));
     return this;
 }