public override void SetState(EntityStates state) { this.state = state; string id = state == EntityStates.Open ? "door-open" : "door-closed"; SetAsset(Resources.Load<Sprite>("Tilesets/Dungeon/Door/" + id)); }
/// <summary> /// Changes the state and change order. /// </summary> /// <param name="descriptorData">The descriptor data.</param> /// <param name="state">The state.</param> /// <param name="changeOrder">The change order.</param> /// <remarks>There is no check that change order is unique as it's expensive. /// Use <see cref="GetNextChangeOrder"/> to treat the change (if any) as latest. /// </remarks> /// <exception cref="TaupoArgumentNullException"> /// When descriptorData is null. /// </exception> /// <exception cref="TaupoInvalidOperationException"> /// When state is Detached, change order is less then 0 or change order is 0 and state is not Unchanged. /// </exception> public void ChangeStateAndChangeOrder(DescriptorData descriptorData, EntityStates state, long changeOrder) { ExceptionUtilities.CheckArgumentNotNull(descriptorData, "descriptorData"); if (state == EntityStates.Detached) { throw new TaupoInvalidOperationException("Cannot create descriptor in a Detached state."); } if (changeOrder < 0) { throw new TaupoInvalidOperationException("Change order cannot be less then 0."); } if (changeOrder == 0 && state != EntityStates.Unchanged) { throw new TaupoInvalidOperationException("Change order cannot be 0 when state is not Unchanged."); } //// Note: there is no check that change order is unique as it's expensive. descriptorData.State = state; descriptorData.ChangeOrder = changeOrder; if (this.nextChangeOrder <= descriptorData.ChangeOrder && descriptorData.ChangeOrder != uint.MaxValue) { this.nextChangeOrder = descriptorData.ChangeOrder + 1; } }
//SecurityGroupCode Object Scope Validation check the entire object for validity... private byte SecurityGroupCodeIsValid(SecurityGroupCode item, out string errorMessage) { //validate key errorMessage = ""; if (string.IsNullOrEmpty(item.SecurityGroupCodeID)) { errorMessage = "ID Is Required."; return(1); } EntityStates entityState = GetSecurityGroupCodeState(item); if (entityState == EntityStates.Added && SecurityGroupCodeExists(item.SecurityGroupCodeID, ClientSessionSingleton.Instance.CompanyID)) { errorMessage = "Item AllReady Exists."; return(1); } //check cached list for duplicates... int count = SecurityGroupCodeList.Count(q => q.SecurityGroupCodeID == item.SecurityGroupCodeID); if (count > 1) { errorMessage = "Item AllReady Exists."; return(1); } //validate Description if (string.IsNullOrEmpty(item.Description)) { errorMessage = "Description Is Required."; return(1); } //a value of 2 is pending changes... //On Commit we will give it a value of 0... return(2); }
//UdList Object Scope Validation check the entire object for validity... private byte UdListIsValid(UdList udList, out string errorMessage) { //validate key errorMessage = ""; if (string.IsNullOrEmpty(udList.UdListID)) { errorMessage = "ID Is Required."; return(1); } EntityStates entityState = GetUdListState(udList); if (entityState == EntityStates.Added && UdListExists(udList.UdListID)) { errorMessage = "Item All Ready Exists."; return(1); } //check cached list for duplicates... int count = UdListList.Count(q => q.UdListID == udList.UdListID); if (count > 1) { errorMessage = "Item All Ready Exists."; return(1); } //validate Description if (string.IsNullOrEmpty(udList.Name)) { errorMessage = "Name Is Required."; return(1); } return(2); }
protected ODataRequestMessageWrapper CreateRequest(EntityDescriptor entityDescriptor) { EntityStates state = entityDescriptor.State; Uri resourceUri = entityDescriptor.GetResourceUri(this.RequestInfo.BaseUriResolver, false); ClientEdmModel model = ClientEdmModel.GetModel(this.RequestInfo.MaxProtocolVersion); Version requestVersion = DetermineRequestVersion(model.GetClientTypeAnnotation(model.GetOrCreateEdmType(entityDescriptor.Entity.GetType())), state); string httpMethod = this.GetHttpMethod(state, ref requestVersion); ODataRequestMessageWrapper requestMessage = this.CreateRequestMessage(resourceUri, httpMethod); if (this.IsBatch) { requestMessage.SetHeader("Content-ID", entityDescriptor.ChangeOrder.ToString(CultureInfo.InvariantCulture)); } if (EntityStates.Deleted != entityDescriptor.State) { requestMessage.SetHeader("Content-Type", "application/atom+xml"); } if ((EntityStates.Deleted == state) || (EntityStates.Modified == state)) { string latestETag = entityDescriptor.GetLatestETag(); if (latestETag != null) { requestMessage.SetHeader("If-Match", latestETag); if (!this.IsBatch) { requestMessage.AddHeadersToReset("If-Match"); } } } ApplyPreferences(requestMessage, httpMethod, this.RequestInfo.AddAndUpdateResponsePreference, ref requestVersion); WebUtil.SetOperationVersionHeaders(requestMessage, requestVersion, this.RequestInfo.MaxProtocolVersionAsVersion); return(requestMessage); }
protected string GetHttpMethod(EntityStates state, ref Version requestVersion) { EntityStates states = state; if (states == EntityStates.Added) { return("POST"); } if (states != EntityStates.Deleted) { if (states != EntityStates.Modified) { throw System.Data.Services.Client.Error.InternalError(InternalError.UnvalidatedEntityState); } } else { return("DELETE"); } if (Util.IsFlagSet(this.Options, SaveChangesOptions.ReplaceOnUpdate)) { return("PUT"); } if (Util.IsFlagSet(this.Options, SaveChangesOptions.PatchOnUpdate)) { WebUtil.RaiseVersion(ref requestVersion, Util.DataServiceVersion3); return("PATCH"); } return("MERGE"); }
//CompanyType Object Scope Validation check the entire object for validity... private byte CompanyTypeIsValid(CompanyType item, out string errorMessage) { //validate key errorMessage = ""; if (string.IsNullOrEmpty(item.CompanyTypeID)) { errorMessage = "ID Is Required."; return(1); } EntityStates entityState = GetCompanyTypeState(item); if (entityState == EntityStates.Added && CompanyTypeExists(item.CompanyTypeID)) { errorMessage = "Item AllReady Exists."; return(1); } int count = CompanyTypeList.Count(q => q.CompanyTypeID == item.CompanyTypeID); if (count > 1) { errorMessage = "Item AllReady Exists."; return(1); } //validate Description if (string.IsNullOrEmpty(item.Description)) { errorMessage = "Description Is Required."; return(1); } //a value of 2 is pending changes... //On Commit we will give it a value of 0... return(2); }
internal void RestoreState(DescriptorState state) { this.changeOrder = state.ChangeOrder; this.saveContentGenerated = state.SaveContentGenerated; this.saveResultProcessed = state.SaveResultProcessed; this.state = state.State; }
internal LinkDescriptor(object source, string sourceProperty, object target, EntityStates state) : base(state) { this.source = source; this.sourceProperty = sourceProperty; this.target = target; }
//Address Object Scope Validation check the entire object for validity... private byte AddressIsValid(Address item, out string errorMessage) { //validate key errorMessage = ""; if (string.IsNullOrEmpty(item.AddressID)) { errorMessage = "ID Is Required."; return(1); } EntityStates entityState = GetAddressState(item); if (entityState == EntityStates.Added && AddressExists(item.AddressID)) { errorMessage = "Item AllReady Exists."; return(1); } //check cached list for duplicates... int count = AddressList.Count(q => q.AddressID == item.AddressID); if (count > 1) { errorMessage = "Item AllReady Exists."; return(1); } //validate Description if (string.IsNullOrEmpty(item.Name)) { errorMessage = "Name Is Required."; return(1); } //a value of 2 is pending changes... //On Commit we will give it a value of 0... return(2); }
//DBStoredImage Object Scope Validation check the entire object for validity... private byte DBStoredImageIsValid(DBStoredImage item, out string errorMessage) { //validate key errorMessage = ""; if (string.IsNullOrEmpty(item.ImageID)) { errorMessage = "ID Is Required."; return(1); } EntityStates entityState = GetDBStoredImageState(item); if (entityState == EntityStates.Added && DBStoredImageExists(item.ImageID)) { errorMessage = "Item AllReady Exists."; return(1); } //check cached list for duplicates... int count = DBStoredImageList.Count(q => q.ImageID == item.ImageID); if (count > 1) { errorMessage = "Item AllReady Exists."; return(1); } ////validate Description //if (string.IsNullOrEmpty(item.Name)) //{ // errorMessage = "Name Is Required."; // return 1; //} ////a value of 2 is pending changes... ////On Commit we will give it a value of 0... return(2); }
private bool CreateRequestData(EntityDescriptor entityDescriptor, ODataRequestMessageWrapper requestMessage) { bool flag = false; EntityStates state = entityDescriptor.State; if (state != EntityStates.Added) { if (state == EntityStates.Deleted) { goto Label_0020; } if (state != EntityStates.Modified) { System.Data.Services.Client.Error.ThrowInternalError(InternalError.UnvalidatedEntityState); goto Label_0020; } } flag = true; Label_0020: if (flag) { this.SerializerInstance.WriteEntry(entityDescriptor, this.RelatedLinks(entityDescriptor), requestMessage); } return(flag); }
public IHttpActionResult UpdateState(StateModel model) { var response = new DataResponse <EntityStates>(); if (ModelState.IsValid) { var entityState = new EntityStates(); entityState.Id = model.Id; entityState.StateName = model.StateName; entityState.StateCode = model.StateCode; entityState.CountryId = model.CountryId; entityState.IsActive = model.IsActive; entityState.UpdatedBy = CurrentUserId; entityState.UpdatedOn = System.DateTime.UtcNow; response = repository.UpdateState(entityState); return(Ok <DataResponse>(response)); } else { var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new { Key = s.Key.Split('.').Last(), Message = s.Value.Errors[0].ErrorMessage }); return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList })); } }
//MenuItem Object Scope Validation check the entire object for validity... private byte MenuItemIsValid(NestedMenuItem item, out string errorMessage) { //validate key errorMessage = ""; if (string.IsNullOrEmpty(item.MenuItemID)) { errorMessage = "ID Is Required."; return(1); } MenuItem menuItem = MenuItemList.FirstOrDefault(q => q.AutoID == item.AutoID); EntityStates entityState = GetMenuItemState(menuItem); if (entityState == EntityStates.Added && MenuItemExists(item.MenuItemID)) { errorMessage = "Item All Ready Exists."; return(1); } //check cached list for duplicates... int count = MenuItemList.Count(q => q.MenuItemID == item.MenuItemID); if (count > 1) { errorMessage = "Item All Ready Exists."; return(1); } //validate Description if (string.IsNullOrEmpty(item.Name)) { errorMessage = "Name Is Required."; return(1); } //a value of 2 is pending changes... //On Commit we will give it a value of 0... return(2); }
internal EntityDescriptor(String identity, Uri selfLink, Uri editLink, object entity, EntityDescriptor parentEntity, string parentProperty, string entitySetName, string etag, EntityStates state) : base(state) { Debug.Assert(entity != null, "entity is null"); Debug.Assert((parentEntity == null && parentProperty == null) || (parentEntity != null && parentProperty != null), "When parentEntity is specified, must also specify parentProperyName"); #if DEBUG if (state == EntityStates.Added) { Debug.Assert(identity == null && selfLink == null && editLink == null && etag == null, "For objects in added state, identity, self-link, edit-link and etag must be null"); Debug.Assert((!String.IsNullOrEmpty(entitySetName) && parentEntity == null && String.IsNullOrEmpty(parentProperty)) || (String.IsNullOrEmpty(entitySetName) && parentEntity != null && !String.IsNullOrEmpty(parentProperty)), "For entities in added state, entity set name or the insert path must be specified"); } else { Debug.Assert(identity != null, "For objects in non-added state, identity must never be null"); Debug.Assert(String.IsNullOrEmpty(entitySetName) && String.IsNullOrEmpty(parentProperty) && parentEntity == null, "For non-added entities, the entity set name and the insert path must be null"); } #endif this.identity = identity; this.selfLink = selfLink; this.editLink = editLink; this.parentDescriptor = parentEntity; this.parentProperty = parentProperty; this.entity = entity; this.etag = etag; this.entitySetName = entitySetName; }
private static void DataServiceCollectionSubQueryTrackingItems( DataServiceContextWrapper <DefaultContainer> contextWrapper) { var query = from p in contextWrapper.Context.Customer where p.Name != null select new Customer() { Name = p.Name, Orders = new DataServiceCollection <Order>( from r in p.Orders select new Order() { OrderId = r.OrderId, CustomerId = r.CustomerId }) }; var tmpResult0 = query.ToList()[0]; DataServiceCollection <Order> collection = tmpResult0.Orders; // the collection tracking items int tmpCount = collection.Count; collection.Load(contextWrapper.Context.Execute(collection.Continuation)); // for testing newly loaded item's tracking Assert.IsTrue(collection.Count > tmpCount, "Should have loaded another page."); bool someItemNotTracked = false; tmpResult0.Orders.ToList().ForEach(s => { EntityStates state = contextWrapper.Context.GetEntityDescriptor(s).State; s.CustomerId = s.CustomerId + 1; state = contextWrapper.Context.GetEntityDescriptor(s).State; someItemNotTracked = (state == EntityStates.Unchanged) || someItemNotTracked; }); Assert.IsFalse(someItemNotTracked, "All items should have been tracked."); }
private static void DataServiceCollectionTrackingItems( DataServiceContextWrapper <DefaultContainer> contextWrapper) { var query = from p in contextWrapper.Context.Customer where p.CustomerId > -100000 // try to get many for paging select new Customer() { CustomerId = p.CustomerId, Name = p.Name }; DataServiceCollection <Customer> collection = new DataServiceCollection <Customer>(query); // the collection to track items int tmpCount = collection.Count; collection.Load(contextWrapper.Context.Execute(collection.Continuation)); // for testing newly loaded item's tracking Assert.IsTrue(collection.Count > tmpCount, "Should have loaded another page."); bool someItemNotTracked = false; collection.ToList().ForEach(s => { s.Name = "value to test tracking"; EntityStates state = contextWrapper.Context.GetEntityDescriptor(s).State; someItemNotTracked = (state == EntityStates.Unchanged) || someItemNotTracked; }); Assert.IsFalse(someItemNotTracked, "All items should have been tracked."); }
public DataResponse <EntityStates> UpdateState(EntityStates entity) { var response = new DataResponse <EntityStates>(); try { base.DBInit(); var model = DBEntity.LookupStates.FirstOrDefault(a => a.Id == entity.Id); model.StateName = entity.StateName; model.StateCode = entity.StateCode; model.CountryId = entity.CountryId; model.IsActive = entity.IsActive; model.UpdatedOn = entity.UpdatedOn; model.UpdatedBy = entity.UpdatedBy; if (base.DBSaveUpdate(model) > 0) { return(GetStateById(model.Id)); } else { response.CreateResponse(DataResponseStatus.InternalServerError); } } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
public override void SetState(EntityStates state) { this.state = state; string id = state == EntityStates.Open ? "door-open" : "door-closed"; SetAsset(Resources.Load <Sprite>("Tilesets/Dungeon/Door/" + id)); }
internal static bool IncludeLinkState(EntityStates x) { if (EntityStates.Modified != x) { return(EntityStates.Unchanged == x); } return(true); }
private static void CheckStateIsNot(EntityStates state, DescriptorData descriptorData, string errorMessage, string argumentName) { if (descriptorData.State == state) { throw new TaupoInvalidOperationException( string.Format(CultureInfo.InvariantCulture, "{0} {1} is in {2} state.", errorMessage, argumentName, state)); } }
public void MoveTo() { _navMeshAgent.SetDestination(_currentDestination); _canon.transform.rotation = Quaternion.Slerp(_canon.transform.rotation, transform.rotation, Time.deltaTime * _angularSpeed); if (Vector3.Distance(_currentDestination, transform.position) < 1) { _state = EntityStates.Neutral; } }
/// <summary> /// Adds a column that shows the state of the row as edited/new /// </summary> /// <param name="columns"></param> public static void AddEditIndicatorColumn(List <Column> columns) { GridDataViewBinder.AddColumn(columns, "", 20, "entityState") .Formatter = delegate(int row, int cell, object value, Column columnDef, object dataContext) { EntityStates state = (EntityStates)value; return(((state == EntityStates.Changed) || (state == EntityStates.Created)) ? "<span class='grid-edit-indicator'></span>" : ""); }; }
public static void init() { ContactsEditorViewModel vm = new ContactsEditorViewModel(); OrganizationServiceProxy.GetUserSettings(); // Data Bind Grid List <Column> columns = GridDataViewBinder.ParseLayout(",entityState,20,First Name,firstname,200,Last Name,lastname,200,Birth Date,birthdate,200,Account Role Code,accountrolecode,200,Number of Children,numberofchildren,100,Currency,transactioncurrencyid,200,Credit Limit,creditlimit,100,Gender,gendercode,100,Owner,ownerid,100"); // Set Column formatters and editors columns[0].Formatter = delegate(int row, int cell, object value, Column columnDef, object dataContext) { EntityStates state = (EntityStates)value; return(((state == EntityStates.Changed) || (state == EntityStates.Created)) ? "<span class='grid-edit-indicator'></span>" : ""); }; // First Name Column XrmTextEditor.BindColumn(columns[1]); // Last Name Column XrmTextEditor.BindColumn(columns[2]); // Birth Date Column XrmDateEditor.BindColumn(columns[3], false); // Account Code Column XrmOptionSetEditor.BindColumn(columns[4], "contact", columns[4].Field, true); // Number of Children Column XrmNumberEditor.BindColumn(columns[5], 0, 100, 0); // Currency Column XrmLookupEditor.BindColumn(columns[6], vm.TransactionCurrencySearchCommand, "transactioncurrencyid", "currencyname", ""); // Credit Limit Column XrmMoneyEditor.BindColumn(columns[7], -10000, 10000); // Another optionset XrmOptionSetEditor.BindColumn(columns[8], "contact", columns[8].Field, true); // OWner Column XrmLookupEditor.BindColumn(columns[9], vm.OwnerSearchCommand, "id", "name", ""); // Create Grid GridDataViewBinder contactGridDataBinder = new GridDataViewBinder(); Grid contactsGrid = contactGridDataBinder.DataBindXrmGrid(vm.Contacts, columns, "container", "pager", true, false); //contactGridDataBinder.BindClickHandler(contactsGrid); // Data Bind ViewBase.RegisterViewModel(vm); Window.SetTimeout(delegate() { vm.Init(); }, 0); }
public override void SetState(EntityStates state) { if (breakable) { state = EntityStates.Closed; } string id = state == EntityStates.Open ? assetType + "-open" : assetType + "-closed"; SetAsset(Resources.Load<Sprite>("Tilesets/Chest/" + id)); this.state = state; }
/// <summary> /// Constructor /// </summary> /// <param name="source">Source entity</param> /// <param name="sourceProperty">Navigation property on the source entity</param> /// <param name="target">Target entity</param> /// <param name="state">The link state</param> internal LinkDescriptor(object source, string sourceProperty, object target, EntityStates state) : base(state) { Debug.Assert(source != null, "source != null"); Debug.Assert(!String.IsNullOrEmpty(sourceProperty), "!String.IsNullOrEmpty(propertyName)"); Debug.Assert(!sourceProperty.Contains("/"), "!sourceProperty.Contains('/')"); this.source = source; this.sourceProperty = sourceProperty; this.target = target; }
/// <summary> /// Creates an entity descriptor data and puts it into the list of entity descriptors data. /// <see cref="ChangeStateAndChangeOrder"/> for the restrictions on the state and change order. /// </summary> /// <param name="state">The state.</param> /// <param name="changeOrder">The change order.</param> /// <param name="entity">The entity.</param> /// <returns>The created entity descriptor data.</returns> /// <exception cref="TaupoArgumentException"> /// When entity is null. /// </exception> public EntityDescriptorData CreateEntityDescriptorData(EntityStates state, long changeOrder, object entity) { ExceptionUtilities.CheckArgumentNotNull(entity, "entity"); var data = new EntityDescriptorData(this, entity); this.ChangeStateAndChangeOrder(data, state, changeOrder); this.entityDatas.Add(data); return data; }
public LinkDescriptor( EntityStates state, Entity source, Relationship relationship, Entity target) : base(state) { this.Source = source; this.Relationship = relationship; this.Target = target; }
internal EntityDescriptor(string identity, Uri selfLink, Uri editLink, Uri addToUri, object entity, EntityDescriptor parentEntity, string parentProperty, string etag, EntityStates state, DataServiceProtocolVersion maxProtocolVersion) : base(state) { this.identity = identity; this.selfLink = selfLink; this.editLink = editLink; this.addToUri = addToUri; this.parentDescriptor = parentEntity; this.parentProperty = parentProperty; this.MaxProtocolVersion = maxProtocolVersion; this.Entity = entity; this.etag = etag; }
internal object TryGetEntity(string resourceUri, out EntityStates state) { state = EntityStates.Detached; EntityDescriptor descriptor = null; if ((this.identityToDescriptor != null) && this.identityToDescriptor.TryGetValue(resourceUri, out descriptor)) { state = descriptor.State; return(descriptor.Entity); } return(null); }
internal void CheckState(DataServiceContext ctx, EntityStates state, Object o) { var type = o.GetType(); foreach (var ed in ctx.Entities) { if (ed.Entity.GetType().Equals(type) && (o).Equals(ed.Entity)) { Assert.Equal(state, ed.State); } } }
/// <summary> /// Creates the link descriptor data and puts in into the list of link descriptors data. /// <see cref="ChangeStateAndChangeOrder"/> for the restrictions on the state and change order. /// </summary> /// <param name="state">The state.</param> /// <param name="changeOrder">The change order.</param> /// <param name="sourceData">The source.</param> /// <param name="sourcePropertyName">Name of the source property.</param> /// <param name="targetData">The target.</param> /// <returns>The created link descriptor data.</returns> /// <exception cref="TaupoArgumentNullException"> /// When source or sourcePropertyName is null. /// </exception> /// <exception cref="TaupoArgumentException"> /// When sourcePropertyName is empty. /// </exception> /// <exception cref="TaupoInvalidOperationException"> /// When entity descriptor data is not found for the source or target (if target is not null). /// </exception> public LinkDescriptorData CreateLinkDescriptorData(EntityStates state, long changeOrder, EntityDescriptorData sourceData, string sourcePropertyName, EntityDescriptorData targetData) { ExceptionUtilities.CheckArgumentNotNull(sourceData, "sourceData"); ExceptionUtilities.CheckArgumentNotNull(sourcePropertyName, "sourcePropertyName"); var linkData = new LinkDescriptorData(sourceData, sourcePropertyName, targetData); this.ChangeStateAndChangeOrder(linkData, state, changeOrder); this.linkDatas.Add(linkData); return linkData; }
public virtual void StateAlive() { if (healthCurrent <= 0) { entityStateCurrent = EntityStates.Dying; if (entityStateCurrent != EntityStates.Dead) { entityStateCurrent = EntityStates.Dead; } } }
/// <summary> /// Creates a new stream descriptor data and adds it to this entity descriptor data /// </summary> /// <param name="state">The state of the stream descriptor data</param> /// <param name="changeOrder">The change order for the stream descriptor data</param> /// <param name="name">The name of the stream</param> /// <returns>The stream descriptor data</returns> public StreamDescriptorData CreateStreamDescriptorData(EntityStates state, long changeOrder, string name) { ExceptionUtilities.CheckArgumentNotNull(name, "name"); ExceptionUtilities.Assert(!this.streamDescriptors.Any(s => s.Name == name), "Stream descriptor data with name '{0}' already exists on entity descriptor data: {1}", name, this); var streamData = new StreamDescriptorData(this, name); this.contextData.ChangeStateAndChangeOrder(streamData, state, changeOrder); this.streamDescriptors.Add(streamData); return(streamData); }
// ===================================================== // Chest generation // ===================================================== public override void Generate() { for (int n = 0; n < dungeonGenerator.rooms.Count; n++) { DungeonRoom room = dungeonGenerator.rooms[n]; int maxChests = Random.Range(0, 100) <= 60 ? Random.Range(1, (int)(room.tiles.Count * 0.1f)) : 0; // place furniture in room for (int i = 1; i <= maxChests; i ++) { Tile tile = GetFreeTileOnRoom(room, 0); if (tile == null) { continue; } Chest chest = (Chest)grid.CreateEntity(typeof(Chest), tile.x, tile.y, 0.7f, null) as Chest; EntityStates[] states = new EntityStates[] { EntityStates.Closed, EntityStates.Locked }; string[] arr = new string[] { "chest", "barrel", "barrel-water", "vase"}; chest.SetChestAssetType(arr[Random.Range(0, arr.Length)]); chest.SetState(states[Random.Range(0, states.Length)]); chest.SetRandomItems(Random.Range(1, 4)); } } }
private static Version DetermineRequestVersion(ClientTypeAnnotation clientType, EntityStates state) { if (state == EntityStates.Deleted) { return Util.DataServiceVersion1; } Version version = Util.DataServiceVersion1; WebUtil.RaiseVersion(ref version, clientType.GetMetadataVersion()); WebUtil.RaiseVersion(ref version, clientType.EpmMinimumDataServiceProtocolVersion.ToVersion()); return version; }
public override void SetState(EntityStates state) { this.state = state; }
public static void Verify(object entity, string uri, EntityStates state, Workspace w) { WebDataCtxWrapper ctx = new WebDataCtxWrapper(w.ServiceRoot); ctx.Credentials = CredentialCache.DefaultNetworkCredentials; MethodInfo mi = ctx.GetType().GetMethod("Execute", new Type[] { typeof(System.Uri) }); MethodInfo execMethod = mi.MakeGenericMethod(entity.GetType()); object results = execMethod.Invoke(ctx, new object[] { new Uri(uri, UriKind.RelativeOrAbsolute) }); switch (state) { case EntityStates.Unchanged: case EntityStates.Modified: case EntityStates.Added: //entity was updated IEnumerator r = ((IEnumerable)results).GetEnumerator(); while (r.MoveNext()) { VerifyResult(r.Current, entity); break; } break; case EntityStates.Deleted: AstoriaTestLog.WriteLineIgnore("deleted!"); break; } }
protected string GetHttpMethod(EntityStates state, ref Version requestVersion) { EntityStates states = state; if (states == EntityStates.Added) { return "POST"; } if (states != EntityStates.Deleted) { if (states != EntityStates.Modified) { throw System.Data.Services.Client.Error.InternalError(InternalError.UnvalidatedEntityState); } } else { return "DELETE"; } if (Util.IsFlagSet(this.Options, SaveChangesOptions.ReplaceOnUpdate)) { return "PUT"; } if (Util.IsFlagSet(this.Options, SaveChangesOptions.PatchOnUpdate)) { WebUtil.RaiseVersion(ref requestVersion, Util.DataServiceVersion3); return "PATCH"; } return "MERGE"; }
public void RaisePropertyChanged(string propertyName) { PropertyChangedEventArgs args = new PropertyChangedEventArgs(); args.PropertyName = propertyName; if (PropertyChanged!=null) PropertyChanged(this, args); if (propertyName != "EntityState" && EntityState == EntityStates.Unchanged && EntityState != EntityStates.Created) EntityState = EntityStates.Changed; }
/// <summary> /// Creates the link descriptor data and puts in into the list of link descriptors data. /// <see cref="ChangeStateAndChangeOrder"/> for the restrictions on the state and change order. /// </summary> /// <param name="state">The state.</param> /// <param name="changeOrder">The change order.</param> /// <param name="source">The source.</param> /// <param name="sourcePropertyName">Name of the source property.</param> /// <param name="target">The target.</param> /// <returns>The created link descriptor data.</returns> /// <exception cref="TaupoArgumentNullException"> /// When source or sourcePropertyName is null. /// </exception> /// <exception cref="TaupoArgumentException"> /// When sourcePropertyName is empty. /// </exception> /// <exception cref="TaupoInvalidOperationException"> /// When entity descriptor data is not found for the source or target (if target is not null). /// </exception> public LinkDescriptorData CreateLinkDescriptorData(EntityStates state, long changeOrder, object source, string sourcePropertyName, object target) { CheckLinkArguments(source, sourcePropertyName); EntityDescriptorData sourceData = this.FindEntityData(source); if (sourceData == null) { throw new TaupoInvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find entity descriptor data for the source: {0}.", source)); } // Target can be null EntityDescriptorData targetData = null; if (target != null) { targetData = this.FindEntityData(target); if (targetData == null) { throw new TaupoInvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find entity descriptor data for the target: {0}.", target)); } } return this.CreateLinkDescriptorData(state, changeOrder, sourceData, sourcePropertyName, targetData); }
public void Unset(EntityStates options) { NoteState &= ~options; }
public virtual void SetState(EntityStates state) { this.state = state; }
internal Descriptor(EntityStates state) { this.state = state; }
public void GenerateQuadTree(QuadTree quadtree) { if (quadtree.HasChildren() == false) { for (int y = quadtree.boundary.BottomTile(); y <= quadtree.boundary.TopTile() - 1; y++) { for (int x = quadtree.boundary.LeftTile(); x <= quadtree.boundary.RightTile() - 1; x++) { // get dungeon tile on the quadtree zone DungeonTile dtile = dungeonGenerator.tiles[y, x]; // In case we want to use different color in each quadtree zone... //Color color = quadtree.color; // create floors if (dtile.id == DungeonTileType.ROOM || dtile.id == DungeonTileType.CORRIDOR || dtile.id == DungeonTileType.DOORH || dtile.id == DungeonTileType.DOORV) { Sprite asset = floorAsset;; if (floorAsset == null) { asset = Resources.Load<Sprite>("Tilesets/Dungeon/Floor/floor-" + Random.Range(1, 5)); } Floor floor = (Floor)grid.CreateTile(typeof(Floor), x, y, 1, asset) as Floor; floor.SetColor(floorColor, true); //floor.SetColor(quadtree.color, true); // set room info in floor tile if (dtile.room != null) { floor.roomId = dtile.room.id; } } // create walls if (dtile.id == DungeonTileType.WALL || dtile.id == DungeonTileType.WALLCORNER) { grid.CreateTile(typeof(Tile), x, y, 1, null); Sprite asset = wallAsset;; if (wallAsset == null) { asset = Resources.Load<Sprite>("Tilesets/Dungeon/Wall/stone-" + Random.Range(1, 5)); } Wall wall = (Wall)grid.CreateEntity(typeof(Wall), x, y, 1, asset) as Wall; wall.SetColor(wallColor, true); } // create doors if (dtile.id == DungeonTileType.DOORH || dtile.id == DungeonTileType.DOORV) { Door door = (Door)grid.CreateEntity(typeof(Door), x, y, 1, null) as Door; EntityStates[] states = new EntityStates[] { EntityStates.Open, EntityStates.Closed, EntityStates.Locked }; door.SetState(states[Random.Range(0, states.Length)]); } } } } else { // Keep iterating on the quadtree GenerateQuadTree(quadtree.northWest); GenerateQuadTree(quadtree.northEast); GenerateQuadTree(quadtree.southWest); GenerateQuadTree(quadtree.southEast); } }
/// <summary> /// Creates a new stream descriptor data and adds it to this entity descriptor data /// </summary> /// <param name="state">The state of the stream descriptor data</param> /// <param name="changeOrder">The change order for the stream descriptor data</param> /// <param name="name">The name of the stream</param> /// <returns>The stream descriptor data</returns> public StreamDescriptorData CreateStreamDescriptorData(EntityStates state, long changeOrder, string name) { ExceptionUtilities.CheckArgumentNotNull(name, "name"); ExceptionUtilities.Assert(!this.streamDescriptors.Any(s => s.Name == name), "Stream descriptor data with name '{0}' already exists on entity descriptor data: {1}", name, this); var streamData = new StreamDescriptorData(this, name); this.contextData.ChangeStateAndChangeOrder(streamData, state, changeOrder); this.streamDescriptors.Add(streamData); return streamData; }
/// <summary>Get the value of the HttpMethod enum from entity resource state</summary> /// <param name="state">resource state</param> /// <param name="requestVersion">The version of the request determined so far. The method may modify this if needed.</param> /// <returns>HttpMethod value from the entity resource state.</returns> protected string GetHttpMethod(EntityStates state, ref Version requestVersion) { switch (state) { case EntityStates.Deleted: return XmlConstants.HttpMethodDelete; case EntityStates.Modified: if (Util.IsFlagSet(this.Options, SaveChangesOptions.ReplaceOnUpdate)) { return XmlConstants.HttpMethodPut; } else { // Default update is PATCH not PUT return XmlConstants.HttpMethodPatch; } case EntityStates.Added: return XmlConstants.HttpMethodPost; default: throw Error.InternalError(InternalError.UnvalidatedEntityState); } }
private static void VerifyStateOfEntities(DataServiceContext ctx, IEnumerable<object> entities, EntityStates expectedState) { Debug.Assert(ctx != null, "ctx != null"); Debug.Assert(entities != null, "entities != null"); foreach (object entity in entities) { EntityDescriptor descriptor = ctx.GetEntityDescriptor(entity); Debug.Assert(descriptor != null, "EntityDescriptor not found for the given entity"); Assert.AreEqual(expectedState, descriptor.State); } }
/// <summary> /// Find tracked entity by its resourceUri and update its etag. /// </summary> /// <param name="resourceUri">resource id</param> /// <param name="state">state of entity</param> /// <returns>entity if found else null</returns> internal abstract object TryGetEntity(Uri resourceUri, out EntityStates state);
internal void CheckState(DataServiceContext ctx, EntityStates state,Object o) { var type = o.GetType(); foreach (var ed in ctx.Entities) { if (ed.Entity.GetType() == type && (o).Equals(ed.Entity)) { Assert.Equal(state, ed.State); } } }
internal object TryGetEntity(string resourceUri, out EntityStates state) { state = EntityStates.Detached; EntityDescriptor descriptor = null; if ((this.identityToDescriptor != null) && this.identityToDescriptor.TryGetValue(resourceUri, out descriptor)) { state = descriptor.State; return descriptor.Entity; } return null; }
internal override object TryGetEntity(Uri resourceUri, out EntityStates state) { state = this.TryGetEntityMethodOutState; return this.TryGetEntityObject(resourceUri); }
/// <summary> /// Find tracked entity by its resourceUri and update its etag. /// </summary> /// <param name="resourceUri">resource id</param> /// <param name="state">state of entity</param> /// <returns>entity if found else null</returns> internal override object TryGetEntity(Uri resourceUri, out EntityStates state) { Debug.Assert(null != resourceUri, "null uri"); state = EntityStates.Detached; EntityDescriptor resource = null; if ((null != this.identityToDescriptor) && this.identityToDescriptor.TryGetValue(resourceUri, out resource)) { state = resource.State; Debug.Assert(null != resource.Entity, "null entity"); return resource.Entity; } return null; }
private EntityStateData(EntityStates state) { this.state = state; }
public bool IsSet(EntityStates option) { return (NoteState & option) == option; }
public void Set(EntityStates options) { NoteState |= options; }