public void Identity_attribute_overrides_multiple_keys() { var descriptor = SimpleDescriptor.Create <MultipleKeysButIdentityForced>(); Assert.IsNotNull(descriptor.Identity); Assert.AreEqual(2, descriptor.Keys.Count); }
public PlaceBase(SimpleDescriptor placeName, HashSet <TriggeredEncounter> optionalInterrupts = null) : base(placeName) { if (optionalInterrupts != null) { interrupts.UnionWith(optionalInterrupts); } }
public virtual void Copy <T>(Descriptor descriptor, IDbConnection connection, IEnumerable <T> entities, IDbTransaction transaction = null, int?commandTimeout = null) { descriptor = descriptor ?? SimpleDescriptor.Create <T>(); var reader = new EnumerableDataReader <T>(entities); var timeout = commandTimeout.HasValue ? commandTimeout.Value : 0; var mapping = GenerateBulkCopyMapping(descriptor, reader, connection, timeout); var settings = BeforeBulkInsert(connection, transaction, timeout); try { using (var bcp = new SqlBulkCopy((SqlConnection)connection, SqlBulkCopyOptions.TableLock, (SqlTransaction)transaction)) { foreach (var column in mapping.DatabaseTableColumns) { bcp.ColumnMappings.Add(new SqlBulkCopyColumnMapping(column, column)); } bcp.BatchSize = reader.Count; bcp.DestinationTableName = !string.IsNullOrWhiteSpace(descriptor.Schema) ? string.Format("[{0}].[{1}]", descriptor.Schema, mapping.DataReaderTable.TableName) : string.Format("[dbo].[{0}]", mapping.DataReaderTable.TableName); bcp.BulkCopyTimeout = timeout; bcp.WriteToServer(reader); } } finally { AfterBulkInsert(connection, transaction, timeout, settings); } }
/// <summary> /// Get the simple descriptor for an endpoint and create the <see cref="ZigBeeEndpoint"> /// /// <param name="endpointId">the endpoint id to request</param> /// <returns>the newly created <see cref="ZigBeeEndpoint"> for the endpoint, or null on error</returns> /// </summary> private async Task <ZigBeeEndpoint> GetSimpleDescriptor(byte endpointId) { SimpleDescriptorRequest simpleDescriptorRequest = new SimpleDescriptorRequest(); simpleDescriptorRequest.DestinationAddress = new ZigBeeEndpointAddress((ushort)Node.NetworkAddress); simpleDescriptorRequest.NwkAddrOfInterest = Node.NetworkAddress; simpleDescriptorRequest.Endpoint = endpointId; CommandResult response = await NetworkManager.SendTransaction(simpleDescriptorRequest, simpleDescriptorRequest); SimpleDescriptorResponse simpleDescriptorResponse = (SimpleDescriptorResponse)response.Response; Log.Debug("{IeeeAddress}: Node SVC Discovery: SimpleDescriptorResponse returned {Response}", Node.IeeeAddress, simpleDescriptorResponse); if (simpleDescriptorResponse == null) { return(null); } if (simpleDescriptorResponse.Status == ZdoStatus.SUCCESS) { ZigBeeEndpoint endpoint = new ZigBeeEndpoint(Node, endpointId); SimpleDescriptor simpleDescriptor = simpleDescriptorResponse.SimpleDescriptor; endpoint.ProfileId = simpleDescriptor.ProfileId; endpoint.DeviceId = simpleDescriptor.DeviceId; endpoint.DeviceVersion = simpleDescriptor.DeviceVersion; endpoint.SetInputClusterIds(simpleDescriptor.InputClusterList.Select(id => id).ToList()); endpoint.SetOutputClusterIds(simpleDescriptor.OutputClusterList.Select(id => id).ToList()); return(endpoint); } return(null); }
public static OptionsRowWrapperBase BuildOptionRow(SimpleDescriptor name, SettingBase setting) { if (setting is null) { return(null); } if (setting is SimpleSetting simple) { return(new OptionsRowButtonWrapper(name, simple.Set, simple.Get, simple.enabledText, simple.disabledText, simple.EnabledHint, simple.DisabledHint, simple.WarnPlayersAboutChanging, simple.SettingEnabled)); } else if (setting is SimpleNullableSetting sn) { return(new OptionsRowButtonWrapper(name, sn.Set, sn.Get, sn.enabledText, sn.disabledText, sn.unsetText, sn.EnabledHint, sn.DisabledHint, sn.UnsetHint, sn.WarnPlayersAboutChanging, sn.SettingEnabled)); } else if (setting is AdvancedSetting advanced) { return(new OptionsRowSliderWrapper(name, advanced.availableOptions, advanced.SelectedSettingText, advanced.SelectedSettingHint, advanced.Get, advanced.Set, advanced.WarnPlayersAboutChanging, advanced.SettingEnabled)); } else if (setting is AdvancedNullableSetting an) { return(new OptionsRowSliderWrapper(name, an.availableOptions, an.SelectedSettingText, an.SelectedSettingHint, an.Get, an.Set, an.WarnPlayersAboutChanging, an.SettingEnabled)); } else { throw new NotSupportedException("This derived type is not (currently) supported. You should never see this."); } }
public EndowmentPerkBase(SimpleDescriptor perkName, SimpleDescriptor buttonStr, SimpleDescriptor perkHintStr, SimpleDescriptor hasPerkText) : base() { nameText = perkName ?? throw new ArgumentNullException(nameof(perkName)); perkText = hasPerkText ?? throw new ArgumentNullException(nameof(hasPerkText)); unlockEndowmentText = perkHintStr ?? throw new ArgumentNullException(nameof(perkHintStr)); buttonText = buttonStr ?? throw new ArgumentNullException(nameof(buttonStr)); }
private protected TattooLocation(TattooSizeLimit limitSize, SimpleDescriptor btnText, SimpleDescriptor locationDesc) { tattooLimit = limitSize ?? throw new ArgumentNullException(nameof(limitSize)); buttonText = btnText ?? throw new ArgumentNullException(nameof(btnText)); description = locationDesc ?? throw new ArgumentNullException(nameof(locationDesc)); }
public DungeonRoom(SimpleDescriptor roomName, Action onFirstEnter, Action onSubsequentEnters) { name = roomName ?? throw new ArgumentNullException(nameof(roomName)); onEnter = onFirstEnter ?? throw new ArgumentNullException(); onReEnter = onSubsequentEnters ?? throw new ArgumentNullException(); }
private OptionsRowButtonWrapper(SimpleDescriptor optionName, Action <bool?> SetState, Func <bool?> GetState, Func <bool?, string> GetText, Func <bool?, string> GetHint, SimpleDescriptor warningText, EnabledOrDisabledWithToolTipNullBtn disabledWithTooltipGetter, bool allowsNull) : base(optionName) { getter = GetState ?? throw new ArgumentNullException(nameof(GetState)); setter = SetState ?? throw new ArgumentNullException(nameof(SetState)); if (GetText is null) { throw new ArgumentNullException(nameof(GetText)); } GetDescriptionText = GetHint ?? throw new ArgumentNullException(nameof(GetHint)); warningTextFn = warningText; enabledFnGetter = disabledWithTooltipGetter ?? throw new ArgumentNullException(nameof(disabledWithTooltipGetter)); string getData(bool?target, bool enabled) { //if enabled FnGetter returns true, we ignore the output. return(enabledFnGetter(target, out string data) ? null : data); } nullable = allowsNull; enabledButton = new AutomaticButtonWrapper(() => GetText(true), () => SetStatus(true), (x) => getData(true, x), null, GetState() != true, false); if (allowsNull) { clearedButton = new AutomaticButtonWrapper(() => GetText(null), () => SetStatus(null), (x) => getData(null, x), null, GetState() != null, false); } else { clearedButton = new AutomaticButtonWrapper(() => "N/A", () => { }, tipCallback: null, null, false, false); clearedButton.SetVisibility(Visibility.Collapsed); } disabledButton = new AutomaticButtonWrapper(() => GetText(false), () => SetStatus(false), (x) => getData(false, x), null, GetState() != false, false); }
public IdleDestinationStorage(Type locationType, ResumeTimeCallback onInterruptCallback, SimpleDescriptor locationCallback, GameDateTime timeToBoogie) { this.locationType = locationType ?? throw new ArgumentNullException(nameof(locationType)); this.locationCallback = locationCallback; this.onInterruptCallback = onInterruptCallback ?? throw new ArgumentNullException(nameof(onInterruptCallback)); travelTime = timeToBoogie ?? throw new ArgumentNullException(nameof(timeToBoogie)); }
public EggPregnancy(Guid creatureID, Guid spawnTypeID, SimpleDescriptor eggText, SimpleDescriptor eggSourceText, ushort spawnTimer, bool largeClutch = false, bool?isLarge = null, Func <bool, EggBase> color = null) : base(creatureID, spawnTypeID, eggText, eggSourceText, spawnTimer) { largeEggs = isLarge ?? Utils.RandBool(); knownEggType = color; eggCount = largeClutch ? Utils.Rand(4) + 6 : Utils.Rand(3) + 5; }
public void Copy <T>(Descriptor descriptor, IDbConnection connection, IEnumerable <T> entities, IDbTransaction transaction = null, int?commandTimeout = null) { descriptor = descriptor ?? SimpleDescriptor.Create <T>(); transaction = transaction ?? connection.BeginTransaction(); var reader = new EnumerableDataReader <T>(entities); var total = reader.Count; var batchSize = total < BatchSize ? total : BatchSize; var pending = new List <object[]>(batchSize); var columnCount = descriptor.Insertable.Count(); var read = 0; while (reader.Read()) { read = ReadOne(columnCount, reader, pending, read); if (pending.Count >= batchSize) { PrepareAndInsert(connection, transaction, descriptor, batchSize, pending); } } if (pending.Count > 0) { PrepareAndInsert(connection, transaction, descriptor, pending.Count, pending); } transaction.Commit(); }
//if null, sets them to default values. protected Species(SimpleDescriptor name /*, GenericCreatureCreator creator*/) { index = indexMaker++; raceDescriptor = name; theSpecies.Add(index, this); //speciesCreator.Add(this, creator); }
public BackgroundItem(string resourcePath, string sidebarResourcePath, SimpleDescriptor backgroundTitle, EnabledOrDisabledWithToolTip disabledWithToolTip, bool darkMode) { path = resourcePath; sidebarPath = sidebarResourcePath; title = backgroundTitle ?? throw new ArgumentNullException(nameof(backgroundTitle)); disabledTooltip = disabledWithToolTip ?? throw new ArgumentNullException(nameof(disabledWithToolTip)); isDarkMode = darkMode; }
protected GillType(ShortPluralDescriptor shortDesc, SimpleDescriptor singleDesc, PartDescriptor <GillData> longDesc, PlayerBodyPartDelegate <Gills> playerDesc, ChangeType <GillData> transform, RestoreType <GillData> restore) : base(PluralHelper(shortDesc), singleDesc, longDesc, playerDesc, transform, restore) { _index = indexMaker++; gills.AddAt(this, _index); pluralDesc = shortDesc; }
public HistoryPerkBase(SimpleDescriptor perkName, SimpleDescriptor buttonStr, SimpleDescriptor perkHintStr, SimpleDescriptor hasPerkText) { nameText = perkName ?? throw new ArgumentNullException(nameof(perkName)); perkText = hasPerkText ?? throw new ArgumentNullException(nameof(hasPerkText)); unlockHistoryText = perkHintStr; buttonText = buttonStr; }
// will probably need father text, youngling text. but for now all i need is the father, i guess. protected StandardSpawnType(Guid creatureID, Guid spawnTypeID, SimpleDescriptor desc, SimpleDescriptor nameOfFather, ushort birthTime) : base(creatureID) { id = spawnTypeID; father = nameOfFather ?? throw new ArgumentNullException(nameof(nameOfFather)); description = desc ?? throw new ArgumentNullException(nameof(desc)); hoursToBirth = birthTime; }
private protected FullBehavior(SimpleDescriptor standardShortDesc, SimpleDescriptor singleShortDesc, PartDescriptor <DataClass> longDesc, PlayerBodyPartDelegate <ContainerClass> playerDesc, ChangeType <DataClass> transformDesc, RestoreType <DataClass> restoreDesc) : base(standardShortDesc, singleShortDesc) { longStr = longDesc ?? throw new ArgumentNullException(nameof(longDesc)); playerStr = playerDesc ?? throw new ArgumentNullException(nameof(playerDesc)); transformFromStr = transformDesc ?? throw new ArgumentNullException(nameof(transformDesc)); restoredStr = restoreDesc ?? throw new ArgumentNullException(nameof(restoreDesc)); }
public GenericBite(ShortDescriptor teethName, byte strength = 1) : base(Attack) { biteStrength = Utils.Clamp2(strength, (byte)0, (byte)5); if (teethName is null) { throw new ArgumentNullException(); } teeth = () => teethName(false); }
internal TailSlam(ShortDescriptor tailName, byte strength = 1) : base(Attack) { attackStrength = Utils.Clamp2(strength, (byte)0, (byte)5); if (tailName is null) { throw new ArgumentNullException(nameof(tailName)); } name = () => tailName(false); }
public EarPiercingLocation(byte index, CompatibleWith allowsJewelryOfType, SimpleDescriptor btnText, SimpleDescriptor locationDesc) : base(allowsJewelryOfType, btnText, locationDesc) { this.index = index; if (!_allLocations.Contains(this)) { _allLocations.Add(this); } }
public void Transients_are_ignored() { var descriptor = SimpleDescriptor.Create <HasTransient>(); Assert.IsNotNull(descriptor); AssertIdentityIsPresent(descriptor); Assert.AreEqual(2, descriptor.All.Count, "All"); // Id, Email, (EmailTrimmed is transient) Assert.AreEqual(1, descriptor.Insertable.Count, "Insertable"); // Email (Id is identity) }
//C# 7.2 magic. basically, prevents it from being messed with except internally. private AntennaeType(ShortPluralDescriptor desc, SimpleDescriptor singleItemDesc, PluralPartDescriptor <AntennaeData> longDesc, PlayerBodyPartDelegate <Antennae> playerDesc, ChangeType <AntennaeData> transformMessage, RestoreType <AntennaeData> revertToDefault) : base(PluralHelper(desc), singleItemDesc, LongPluralHelper(longDesc), playerDesc, transformMessage, revertToDefault) { shortPluralDesc = desc ?? throw new ArgumentNullException(nameof(desc)); longPluralDesc = longDesc ?? throw new ArgumentNullException(nameof(longDesc)); _index = indexMaker++; antennaes.AddAt(this, _index); }
//Constructor for an behavior that only has one member. This format allows a common function to be used for both formats, and a flag to alter the text //to match the required type. private protected BehaviorBase(ShortDescriptor shortDescFn) { if (shortDescFn is null) { throw new ArgumentNullException(nameof(shortDescFn)); } //doesn't matter, the value is ignored. shortDesc = () => shortDescFn(false); singleDesc = () => shortDescFn(true); }
public CaninePepperGeneric(CanineModifiers canineModifiers, SimpleDescriptor abbreviatedName, SimpleDescriptor itemName, ItemDescriptor itemDescription, SimpleDescriptor appearance, int value = 10) : base() { modifiers = canineModifiers; monetaryValue = value; abbreviated = abbreviatedName ?? throw new ArgumentNullException(nameof(abbreviatedName)); name = itemName ?? throw new ArgumentNullException(nameof(itemName)); description = itemDescription ?? throw new ArgumentNullException(nameof(itemDescription)); appearText = appearance ?? throw new ArgumentNullException(nameof(appearance)); }
public void Getting_and_setting_works_against_an_accessor() { var user = new SimpleUser(); var descriptor = SimpleDescriptor.Create <SimpleUser>(); var accessor = descriptor[0].Property; accessor.Set(user, 5); var value = accessor.Get(user); Assert.AreEqual(5, value); }
public GenericUpperGarment(Guid upperGarmentID, SimpleDescriptor abbreviated, SimpleDescriptor fullName, ItemDescriptor descriptor, SimpleDescriptor about, double defense, byte sexiness, int price) { uniqueID = upperGarmentID; this.abbreviated = abbreviated ?? throw new ArgumentNullException(nameof(abbreviated)); this.fullName = fullName ?? throw new ArgumentNullException(nameof(fullName)); this.descriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor)); this.about = about ?? throw new ArgumentNullException(nameof(about)); this.defense = defense; this.sexiness = sexiness; this.price = price; }
protected EarType(bool internalEar, ShortPluralDescriptor shortDesc, SimpleDescriptor singleItemDesc, PluralPartDescriptor <EarData> longDesc, PlayerBodyPartDelegate <Ears> playerDesc, ChangeType <EarData> transform, RestoreType <EarData> restore) : base(PluralHelper(shortDesc), singleItemDesc, LongPluralHelper(longDesc), playerDesc, transform, restore) { shortPluralDesc = shortDesc; longPluralDesc = longDesc; _index = indexMaker++; ears.AddAt(this, id); isInternalEar = internalEar; }
private Conjugate(SimpleDescriptor possessiveNoun, SimpleDescriptor possessiveAdjective, SimpleDescriptor personalNoun, SimpleDescriptor objectNoun, SimpleDescriptor reflexiveNoun, SimpleDescriptor personalWithHave, SimpleDescriptor personalWithAre) { this.possessiveNoun = possessiveNoun ?? throw new ArgumentNullException(nameof(possessiveNoun)); this.possessiveAdjective = possessiveAdjective ?? throw new ArgumentNullException(nameof(possessiveAdjective)); this.personalNoun = personalNoun ?? throw new ArgumentNullException(nameof(personalNoun)); this.objectNoun = objectNoun ?? throw new ArgumentNullException(nameof(objectNoun)); this.reflexiveNoun = reflexiveNoun ?? throw new ArgumentNullException(nameof(reflexiveNoun)); this.personalNounWithHave = personalWithHave ?? throw new ArgumentNullException(nameof(personalWithHave)); this.personalNounWithAre = personalWithAre ?? throw new ArgumentNullException(nameof(personalWithAre)); }
public CreditCategoryBase(SimpleDescriptor categoryStr, SubCategory[] initialSubCategories) { CreditCategoryText = categoryStr ?? throw new ArgumentNullException(nameof(categoryStr)); if (initialSubCategories is null) { initialSubCategories = new SubCategory[0]; } subcategorySource = new List <SubCategory>(initialSubCategories); subCategories = new ReadOnlyCollection <SubCategory>(subcategorySource); }
public Animation(SimpleDescriptor descriptor) : this(descriptor.AssetName, descriptor.Width, descriptor.Height, descriptor.Frames.ToArray()) { SpeedMultiplier = descriptor.Speed; Play(); }