Пример #1
0
        static bool Prefix(ref Verse.Name __result, Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
        {
            FemaleNames nameGenF = new FemaleNames();
            MaleNames   nameGenM = new MaleNames();
            NameTriple  temp     = pawn.Name as NameTriple;


            if (pawn.RaceProps.Animal && pawn.Name == null)
            {
                //這裡就走原生的路線
                // __result = new NameTriple("小","動","物") ;
                return(true);
            }

            if (pawn.gender == Gender.Female)
            {
                __result = nameGenF.GetChineseFemaleName(pawn);
            }
            else
            {
                __result = nameGenM.GetChineseMaleName(pawn);
            }

            return(false);
        }
Пример #2
0
 private static WaitHandleDistributedSemaphore CreateAsLock(string name, NameStyle nameStyle) =>
 new WaitHandleDistributedSemaphore(
     nameStyle == NameStyle.AddPrefix ? DistributedWaitHandleHelpers.GlobalPrefix + name : name,
     maxCount: 1,
     abandonmentCheckCadence: TimeSpan.FromSeconds(.3),
     exactName: nameStyle != NameStyle.Safe
     );
Пример #3
0
        public static string AddSuffix(NameStyle nameStyle, string name, int i)
        {
            if (i < 1)
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder(name);

            sb.Append(" ");

            switch (nameStyle)
            {
            case NameStyle.Numerical:
                sb.Append(i);
                break;

            case NameStyle.Alphabetical:
                sb.Append((Char)((65) + (i - 1)));
                break;

            case NameStyle.Greek:
                sb.Append(GreekSuffixes[i - 1]);
                break;

            case NameStyle.Roman:
                sb.Append(i.ToRoman());
                break;
            }

            return(sb.ToString().Trim());
        }
 public static Name GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
 {
     if (style == NameStyle.Full)
     {
         RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);
         if (nameGenerator != null)
         {
             string name = NameGenerator.GenerateName(nameGenerator, (string x) => !new NameSingle(x, false).UsedThisGame, false, null);
             return(new NameSingle(name, false));
         }
         if (pawn.Faction != null && pawn.Faction.def.pawnNameMaker != null)
         {
             string rawName = NameGenerator.GenerateName(pawn.Faction.def.pawnNameMaker, delegate(string x)
             {
                 NameTriple nameTriple4 = NameTriple.FromString(x);
                 nameTriple4.ResolveMissingPieces(forcedLastName);
                 return(!nameTriple4.UsedThisGame);
             }, false, null);
             NameTriple nameTriple = NameTriple.FromString(rawName);
             nameTriple.CapitalizeNick();
             nameTriple.ResolveMissingPieces(forcedLastName);
             return(nameTriple);
         }
         if (pawn.RaceProps.nameCategory != PawnNameCategory.NoName)
         {
             if (Rand.Value < 0.5f)
             {
                 NameTriple nameTriple2 = PawnBioAndNameGenerator.TryGetRandomUnusedSolidName(pawn.gender, forcedLastName);
                 if (nameTriple2 != null)
                 {
                     return(nameTriple2);
                 }
             }
             return(PawnBioAndNameGenerator.GeneratePawnName_Shuffled(pawn, forcedLastName));
         }
         Log.Error("No name making method for " + pawn);
         NameTriple nameTriple3 = NameTriple.FromString(pawn.def.label);
         nameTriple3.ResolveMissingPieces(null);
         return(nameTriple3);
     }
     else
     {
         if (style == NameStyle.Numeric)
         {
             int    num = 1;
             string text;
             while (true)
             {
                 text = pawn.KindLabel + " " + num.ToString();
                 if (!NameUseChecker.NameSingleIsUsed(text))
                 {
                     break;
                 }
                 num++;
             }
             return(new NameSingle(text, true));
         }
         throw new InvalidOperationException();
     }
 }
Пример #5
0
        public override Dictionary <string, NameGenerator> Prepare(NameStyle style)
        {
            this.canonNames = File.ReadAllLines(string.Format("Data\\{0}{1}.txt", style.Name, this.Settings.Gender));
            var result = new Dictionary <string, NameGenerator>();

            result.Add("name", new NameGenerator(this.canonNames, this.Settings));
            return(result);
        }
Пример #6
0
        public Type TestBadName(string?name, NameStyle nameStyle)
        {
            if (name != null)
            {
                this.TestWorkingName(name, NameStyle.Safe); // should always work
            }

            return(Assert.Catch(() => CreateAsLock(name !, nameStyle)).GetType());
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RealNames"/> class.
        /// </summary>
        /// <param name="nameStyle">
        /// The style how the name shall be generated.
        /// </param>
        public RealNames(NameStyle nameStyle)
        {
            this.nameStyle = nameStyle;

            if (this.nameStyle != NameStyle.LastName)
            {
                this.firstNames = Resources.FirstNames.Split(';');
            }

            if (this.nameStyle != NameStyle.FirstName)
            {
                this.lastNames = Resources.LastNames.Split(';');
            }
        }
Пример #8
0
        public static Name _GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
        {
            if (style == NameStyle.Full)
            {
                if (rnd.NextDouble() < 0.2)
                {
                    if (names [pawn.gender].Count == 0)
                    {
                        Log.Message(pawn.gender.ToString() + " Name database reset");
                        Messages.Message(pawn.gender.ToString() + " Name database reset", MessageSound.Silent);

                        // pawn.gender
                        names[pawn.gender] = new List <NameTriple>(originalNames[pawn.gender]);
                    }

                    NameTriple name;
                    names[pawn.gender].TryRandomElement(out name);
                    names[pawn.gender].Remove(name);
                    return(name);
                }
                else
                {
                    return(GeneratePawnName(pawn, style, forcedLastName));
                }
            }
            else
            {
                if (style == NameStyle.Numeric)
                {
                    int    num = 1;
                    string text;
                    while (true)
                    {
                        text = pawn.KindLabel + " " + num.ToString();
                        if (!NameUseChecker.NameSingleIsUsed(text))
                        {
                            break;
                        }
                        num++;
                    }
                    return(new NameSingle(text, true));
                }
                throw new InvalidOperationException();
            }
        }
        public static Name _GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
        {
            if (style == NameStyle.Full)
            {
                NameTriple name;

                if (solidNames[pawn.gender].Count <= 0)
                {
                    Log.Message(pawn.gender.ToString() + " Name database reset");
                    Messages.Message(pawn.gender.ToString() + " Name database reset", MessageSound.Silent);

                    while (usedNames[pawn.gender].Count > 0)
                    {
                        solidNames[pawn.gender].Add(usedNames[pawn.gender].Dequeue());
                    }
                }

                solidNames[pawn.gender].TryRandomElement(out name);

                solidNames[pawn.gender].Remove(name);
                usedNames[pawn.gender].Enqueue(name);
                return(name);
            }
            else
            {
                if (style == NameStyle.Numeric)
                {
                    int    num = 1;
                    string text;
                    while (true)
                    {
                        text = pawn.KindLabel + " " + num.ToString();
                        if (!NameUseChecker.NameSingleIsUsedOnAnyMap(text))
                        {
                            break;
                        }
                        num++;
                    }
                    return(new NameSingle(text, true));
                }
                throw new InvalidOperationException();
            }
        }
Пример #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (AdditionalContactInfo == null ? 0 : AdditionalContactInfo.GetHashCode());
         hash = hash * 23 + (BusinessEntityId == default(int) ? 0 : BusinessEntityId.GetHashCode());
         hash = hash * 23 + (Demographics == null ? 0 : Demographics.GetHashCode());
         hash = hash * 23 + (EmailPromotion == default(int) ? 0 : EmailPromotion.GetHashCode());
         hash = hash * 23 + (FirstName == null ? 0 : FirstName.GetHashCode());
         hash = hash * 23 + (LastName == null ? 0 : LastName.GetHashCode());
         hash = hash * 23 + (MiddleName == null ? 0 : MiddleName.GetHashCode());
         hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode());
         hash = hash * 23 + (NameStyle == default(bool) ? 0 : NameStyle.GetHashCode());
         hash = hash * 23 + (PersonType == null ? 0 : PersonType.GetHashCode());
         hash = hash * 23 + (Rowguid == default(Guid) ? 0 : Rowguid.GetHashCode());
         hash = hash * 23 + (Suffix == null ? 0 : Suffix.GetHashCode());
         hash = hash * 23 + (Title == null ? 0 : Title.GetHashCode());
         return(hash);
     }
 }
Пример #11
0
        // RimWorld.PawnBioAndNameGenerator
        public static void GeneratePawnName(Pawn pawn, NameStyle style, string forcedLastName, ref Name __result)
        {
            if (pawn != null && pawn.Faction != null && pawn.Faction.def.defName == "RE_Player")
            {
                var ruleMaker = pawn.gender ==
                                Gender.Female ?
                                DefDatabase <RulePackDef> .GetNamed("RE_STARSNamerFemale")
                    :
                                DefDatabase <RulePackDef> .GetNamed("RE_STARSNamerMale");

                string rawName = NameGenerator.GenerateName(ruleMaker, delegate(string x)
                {
                    NameTriple nameTriple4 = NameTriple.FromString(x);
                    nameTriple4.ResolveMissingPieces(forcedLastName);
                    return(!nameTriple4.UsedThisGame);
                });
                NameTriple nameTriple = NameTriple.FromString(rawName);
                nameTriple.CapitalizeNick();
                nameTriple.ResolveMissingPieces(forcedLastName);
                __result = nameTriple;
            }
        }
 public Dictionary <string, NameGenerator> Prepare(NameStyle style, NameSettings settings)
 {
     this.Settings = settings;
     return(this.Prepare(style));
 }
Пример #13
0
 public XmlSerializableAttribute(NameStyle nameStyle, Type xmlAttributeType)
 {
 }
Пример #14
0
        // Get the text name for a control. THe Name Style controls how the control points appear:
        // Long:  "Control 32", "Start", "Finish", "Mandatory crossing point".
        // Medium: "32", "Start", "Finish", "Crossing"
        // Short: "32", "S", "F", "C"
        public static string ControlPointName(EventDB eventDB, Id <ControlPoint> controlId, NameStyle style)
        {
            ControlPoint control = eventDB.GetControl(controlId);

            // Control name/code.
            switch (control.kind)
            {
            case ControlPointKind.Normal:
                if (style == NameStyle.Long)
                {
                    return(string.Format(MiscText.Control_Code, control.code));
                }
                else
                {
                    return(string.Format("{0}", control.code));
                }

            case ControlPointKind.Start:
                if (style == NameStyle.Short)
                {
                    return(MiscText.Start_Short);
                }
                else
                {
                    return(MiscText.Start);
                }

            case ControlPointKind.Finish:
                if (style == NameStyle.Short)
                {
                    return(MiscText.Finish_Short);
                }
                else
                {
                    return(MiscText.Finish);
                }

            case ControlPointKind.CrossingPoint:
                if (style == NameStyle.Long)
                {
                    return(MiscText.MandCrossing_Long);
                }
                else if (style == NameStyle.Medium)
                {
                    return(MiscText.MandCrossing_Medium);
                }
                else
                {
                    return(MiscText.MandCrossing_Short);
                }

            case ControlPointKind.MapExchange:
                if (style == NameStyle.Long)
                {
                    return(MiscText.MapExchange_Long);
                }
                else if (style == NameStyle.Medium)
                {
                    return(MiscText.MapExchange_Medium);
                }
                else
                {
                    return(MiscText.MapExchange_Short);
                }

            case ControlPointKind.MapIssue:
                if (style == NameStyle.Long)
                {
                    return(MiscText.MapIssue_Long);
                }
                else if (style == NameStyle.Medium)
                {
                    return(MiscText.MapIssue_Medium);
                }
                else
                {
                    return(MiscText.MapIssue_Short);
                }

            default:
                Debug.Fail("bad control kind");
                return("");
            }
        }
        public static Name GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
        {
            switch (style)
            {
            case NameStyle.Full:
            {
                if (pawn.story != null)
                {
                    if (pawn.story.childhood != null && pawn.story.childhood.NameMaker != null)
                    {
                        return(NameResolvedFrom(pawn.story.childhood.NameMaker, forcedLastName));
                    }
                    if (pawn.story.adulthood != null && pawn.story.adulthood.NameMaker != null)
                    {
                        return(NameResolvedFrom(pawn.story.adulthood.NameMaker, forcedLastName));
                    }
                }
                RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);
                if (nameGenerator != null)
                {
                    return(new NameSingle(NameGenerator.GenerateName(nameGenerator, (string x) => !new NameSingle(x).UsedThisGame)));
                }
                if (pawn.Faction != null)
                {
                    RulePackDef nameMaker = pawn.Faction.def.GetNameMaker(pawn.gender);
                    if (nameMaker != null)
                    {
                        return(NameResolvedFrom(nameMaker, forcedLastName));
                    }
                }
                if (pawn.RaceProps.nameCategory != 0)
                {
                    if (Rand.Value < 0.5f)
                    {
                        NameTriple nameTriple = TryGetRandomUnusedSolidName(pawn.gender, forcedLastName);
                        if (nameTriple != null)
                        {
                            return(nameTriple);
                        }
                    }
                    return(GeneratePawnName_Shuffled(pawn, forcedLastName));
                }
                Log.Error("No name making method for " + pawn);
                NameTriple nameTriple2 = NameTriple.FromString(pawn.def.label);
                nameTriple2.ResolveMissingPieces();
                return(nameTriple2);
            }

            case NameStyle.Numeric:
                try
                {
                    foreach (Pawn item in PawnsFinder.AllMapsWorldAndTemporary_AliveOrDead)
                    {
                        NameSingle nameSingle = item.Name as NameSingle;
                        if (nameSingle != null)
                        {
                            usedNamesTmp.Add(nameSingle.Name);
                        }
                    }
                    int    num = 1;
                    string text;
                    while (true)
                    {
                        text = $"{pawn.KindLabel} {num.ToString()}";
                        if (!usedNamesTmp.Contains(text))
                        {
                            break;
                        }
                        num++;
                    }
                    return(new NameSingle(text, numerical: true));
                }
                finally
                {
                    usedNamesTmp.Clear();
                }

            default:
                throw new InvalidOperationException();
            }
        }
Пример #16
0
        public static bool Prefix(Pawn pawn, ref Name __result, NameStyle style = 0, string forcedLastName = null)
        {
            if (style != NameStyle.Full)
            {
                return(true);
            }
            RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);

            if (nameGenerator != null)
            {
                if (nameGenerator.defName.Contains("NamerAnimalGeneric"))
                {
                    if (pawn.Faction != null && (pawn.Faction.def.defName.Contains("Tribe") || pawn.Faction.def.defName == "TribalRaiders"))
                    {
                        string        name;
                        RTPN_NameBank nameBank = RTPN_Initializer.BankOf(PawnNameCategory.HumanStandard);
                        name = nameBank.GetName(RTPN_NameSlot.Tribal, pawn.gender);
                        if (Rand.Value < 0.33f)
                        {
                            string subname1;
                            string subname2;
                            float  nickDesc = Rand.Value;
                            if (nickDesc < 0.25)
                            {
                                subname1 = nameBank.GetName(RTPN_NameSlot.Desc, Gender.Female);
                            }
                            else
                            {
                                subname1 = nameBank.GetName(RTPN_NameSlot.Desc, Gender.Male);
                            }
                            float nickObject = Rand.Value;
                            if (nickObject < 0.33)
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.Male);
                            }
                            else if (nickObject < 0.67)
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.Female);
                            }
                            else
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.None);
                            }
                            if (Rand.Value < 0.1)
                            {
                                name = subname2;
                            }
                            else
                            {
                                name = string.Concat(subname1, " ", subname2);
                            }
                        }
                        __result = new NameSingle(name, false);
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                return(true);
            }
            if (pawn.Faction != null && pawn.Faction.def.pawnNameMaker != null)
            {
                if (pawn.Faction.def.pawnNameMaker.defName.Contains("NamerPersonTribal"))
                {
                    string        name1;
                    string        name2;
                    string        name3;
                    RTPN_NameBank nameBank = RTPN_Initializer.BankOf(PawnNameCategory.HumanStandard);
                    name3 = nameBank.GetName(RTPN_NameSlot.Tribal, pawn.gender);
                    name1 = nameBank.GetName(RTPN_NameSlot.Tribal, pawn.gender);
                    int num = 0;
                    do
                    {
                        num++;
                        if (Rand.Value >= 0.33f)
                        {
                            name2 = (Rand.Value >= 0.67f ? name3 : name1);
                        }
                        else
                        {
                            string subname1;
                            string subname2;
                            float  nickDesc = Rand.Value;
                            if (nickDesc < 0.25)
                            {
                                subname1 = nameBank.GetName(RTPN_NameSlot.Desc, Gender.Female);
                            }
                            else
                            {
                                subname1 = nameBank.GetName(RTPN_NameSlot.Desc, Gender.Male);
                            }
                            float nickObject = Rand.Value;
                            if (nickObject < 0.33)
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.Male);
                            }
                            else if (nickObject < 0.67)
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.Female);
                            }
                            else
                            {
                                subname2 = nameBank.GetName(RTPN_NameSlot.Object, Gender.None);
                            }
                            if (Rand.Value < 0.1)
                            {
                                name2 = subname2;
                            }
                            else
                            {
                                name2 = string.Concat(subname1, " ", subname2);
                            }
                        }
                    }while (num < 50 && NameUseChecker.AllPawnsNamesEverUsed.Any <Name>((Name x) => {
                        NameTriple nameTriple = x as NameTriple;
                        return(nameTriple == null ? false : nameTriple.Nick == name2);
                    }));
                    name1 = name1 + " '" + name2 + "'";
                    NameTriple fullName = NameTriple.FromString(name1 + " " + name3);
                    fullName.CapitalizeNick();
                    fullName.ResolveMissingPieces(null);
                    __result = fullName;
                    return(false);
                }
            }
            return(true);
        }
 public abstract Dictionary <string, NameGenerator> Prepare(NameStyle style);
Пример #18
0
 public void TestWorkingName(string name, NameStyle nameStyle) =>
 Assert.DoesNotThrow(() => CreateAsLock(name, nameStyle).Acquire().Dispose());
Пример #19
0
 public XmlSerializableAttribute(NameStyle nameStyle)
 {
 }
Пример #20
0
        private static bool CuteboldGeneratePawnNamePrefix(Pawn pawn, ref Name __result, NameStyle style = NameStyle.Full, string forcedLastName = null)
        {
            //Log.Message("Generate Pawn Name Prefix");
            //Log.Message("  pawn def=" + pawn.def.ToString() + " style=" + style.ToString());

            if (pawn.def?.defName != Cutebold_Assemblies.RaceName || style != NameStyle.Full)
            {
                return(true);
            }

            //Log.Message("  pawn faction=" + pawn.Faction.ToString() + "  faction name maker="+((pawn.Faction != null && pawn.Faction.def.pawnNameMaker != null) ? pawn.Faction.def.pawnNameMaker.ToString() : ""));
            RulePackDef rulePack = pawn.Faction?.ideos?.PrimaryCulture.pawnNameMaker;

// 1.1      RulePackDef rulePack = pawn.Faction?.def.pawnNameMaker;

            // Cutebolds with no faction pawn name maker
            if (rulePack == null)
            {
                //Log.Message("  Faction null or pawnNameMaker null");
                if (pawn.story.childhood == null || (pawn.story.adulthood != null && CuteboldRegularChildBackstories.Contains(pawn.story.childhood) && CuteboldRegularAdultBackstories.Contains(pawn.story.adulthood))) // Cutebold somehow does not have a childhood or is from a cutebold tribe
                {
                    //Log.Message("    Regular Cutebold");
                    rulePack = Cutebold_DefOf.NamerPersonCutebold;
                }
                else if (CuteboldSlaveChildBackstories.Contains(pawn.story.childhood)) // Cutebold was a cutebold child slave
                {
                    //Log.Message("    Slave Child Cutebold");
                    rulePack = Cutebold_DefOf.NamerPersonCuteboldSlave;
                }
                else if (CuteboldRegularChildBackstories.Contains(pawn.story.childhood) || (pawn.story.adulthood != null && CuteboldRegularAdultBackstories.Contains(pawn.story.adulthood))) // Cutebold either joined or left a cutebold tribe during their lifetime
                {
                    //Log.Message("    Other Cutebold");
                    rulePack = pawn.gender == Verse.Gender.Female ? Cutebold_DefOf.NamerPersonCuteboldOtherFemale : Cutebold_DefOf.NamerPersonCuteboldOther;
                }
                else // Cutebold is an outsider
                {
                    //Log.Message("    Outsider Cutebold");
                    rulePack = pawn.gender == Verse.Gender.Female ? Cutebold_DefOf.NamerPersonCuteboldOutsiderFemale : Cutebold_DefOf.NamerPersonCuteboldOutsider;
                }

                // We want servants to have a full first and last name.
                if (pawn.story.adulthood != null && CuteboldServantAdultBackstories.Contains(pawn.story.adulthood))
                {
                    //Log.Message("    Servant Cutebold");
                    rulePack = pawn.gender == Verse.Gender.Female ? Cutebold_DefOf.NamerPersonCuteboldOutsiderFemale : Cutebold_DefOf.NamerPersonCuteboldOutsider;
                }
            }
            // Cutebold slaves/servants
            else if (pawn.story.adulthood != null && CuteboldServantAdultBackstories.Contains(pawn.story.adulthood)) // Cutebold servents get a full name
            {
                //Log.Message("  Cutebold with faction and pawnNameMaker");
                //Log.Message("    Servant Cutebold");
                rulePack = pawn.gender == Gender.Female ? Cutebold_DefOf.NamerPersonCuteboldOutsiderFemale : Cutebold_DefOf.NamerPersonCuteboldOutsider;
            }
            else if (pawn.story.childhood != null && CuteboldSlaveChildBackstories.Contains(pawn.story.childhood)) // Cutebold child slaves get a simple name
            {
                //Log.Message("  Cutebold with faction and pawnNameMaker");
                //Log.Message("    Slave Child Cutebold");
                rulePack = Cutebold_DefOf.NamerPersonCuteboldSlave;
            }

            if (rulePack != null)
            {
                NameTriple tempName = CuteboldNameGenerator(rulePack, forcedLastName);

                if (tempName.Nick.EndsWith("za") && pawn.gender != Gender.Female)
                {
                    __result = new NameTriple(tempName.First, tempName.Nick.TrimEnd('a'), tempName.Last);
                }
                else
                {
                    __result = tempName;
                }

                return(false);
            }
            else
            {
                //Log.Message("RulePack still null, using regular name generator.");
                return(true);
            }
        }
Пример #21
0
 /// <summary>
 /// 树子结点列表
 /// </summary>
 /// <param name="id">父结点ID</param>
 /// <param name="nameStyle">地区显示类型</param>
 /// <returns>树子结点列表</returns>
 private List<LiveTreeNode> ListTreeNode(Guid id, NameStyle nameStyle)
 {
     Guid? gNodeID = null;
     // 当展开root节点的时候
     if (id != Guid.Empty)
         gNodeID = id;
     List<GeneralRegion> oRegions = (from r in dbEntity.GeneralRegions.Include("ChildItems")
                                     where (gNodeID == null ? r.aParent == null : r.aParent == gNodeID)
                                        && (r.Deleted == false)
                                     orderby r.Sorting descending
                                     select r).ToList();
     Func<GeneralRegion, string> GetName;
     if (nameStyle == NameStyle.FullName)
         GetName = (item => item.FullName);
     else
         GetName = (item => item.ShortName);
     List<LiveTreeNode> list = (from item in oRegions
                                select new LiveTreeNode
                                {
                                    id = item.Gid.ToString(),
                                    name = GetName(item),
                                    isParent = (item.ChildCount > 0)
                                }).ToList();
     return list;
 }
Пример #22
0
 private static EventWaitHandleDistributedLock CreateLock(string name, NameStyle nameStyle) =>
 new EventWaitHandleDistributedLock(
     (nameStyle == NameStyle.AddPrefix ? DistributedWaitHandleHelpers.GlobalPrefix + name : name),
     abandonmentCheckCadence: TimeSpan.FromSeconds(.3),
     exactName: nameStyle != NameStyle.Safe
     );