public FieldMapAttribute(string fieldName, Type dataType, bool allowNull) { this._Identity = false; this._IdentSeed = 1; this._IdentIncr = 1; this._BlobType = BlobTypes.None; this._FieldName = fieldName.ToLower().Trim(); this._DataType = dataType; this._AllowNull = allowNull; this._Scale = 0; }
public FieldMapAttribute(string fieldName, BlobTypes blobType) : this(fieldName, typeof(byte[]), true) { this._BlobType = blobType; }
public void SetBlobType(BlobCharacter.BlobTypes blobType) { this.blobType = blobType; }
private void UpdateShapeProperties(BlobCharacter.BlobTypes blobType) { this.spriteRenderer.sprite = Resources.Load<Sprite>("Images/Blob_" + ((int) blobType +1) + "/Blob_" + ((int) blobType+1)); this.animator.runtimeAnimatorController = Resources.Load<AnimatorOverrideController>("Animators/Blob" + ((int) blobType+1)); this.previousBlobType = this.blobType; }
protected void AssociateBlobProperties() { for (int index = 0; index < Properties.Count; ++index) { MessageSerializedPropertyInfo currentPropertyInfo = Properties[index]; BlobTypes currentBlobType = currentPropertyInfo.MessagePropertyAttribute.BlobType; if (currentBlobType == BlobTypes.Length) { // If an associated blob property is specified we just want to find that one after this one and make sure it doesn't have a different association and assign it. // If there isn't one specified we just want to find the next blob field and assign that one. string lengthAssociatedBlobProperty = currentPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty; if (string.IsNullOrEmpty(lengthAssociatedBlobProperty)) { for (int blobDataIndex = index + 1; blobDataIndex < Properties.Count; ++blobDataIndex) { MessageSerializedPropertyInfo blobDataPropertyInfo = Properties[blobDataIndex]; if (blobDataPropertyInfo.MessagePropertyAttribute.BlobType == BlobTypes.Data) { string dataAssociatedBlobProperty = blobDataPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty; if (!string.IsNullOrEmpty(dataAssociatedBlobProperty) && dataAssociatedBlobProperty != currentPropertyInfo.PropertyInfo.Name) { throw new Exception(string.Format("Blob Length Property {0} with no explicit association should have Blob Data Property {1} as its associated blob data but {1} has {2} as its associated length field", currentPropertyInfo.PropertyInfo.Name, blobDataPropertyInfo.PropertyInfo.Name, dataAssociatedBlobProperty)); } blobDataPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty = currentPropertyInfo.PropertyInfo.Name; currentPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty = blobDataPropertyInfo.PropertyInfo.Name; break; } } if (string.IsNullOrEmpty(currentPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty)) { throw new Exception(string.Format("Couldn't find an associated blob data field for blob length field {0}", currentPropertyInfo.PropertyInfo.Name)); } } else { for (int blobDataIndex = index + 1; blobDataIndex < Properties.Count; ++blobDataIndex) { MessageSerializedPropertyInfo blobDataPropertyInfo = Properties[blobDataIndex]; if (blobDataPropertyInfo.PropertyInfo.Name == lengthAssociatedBlobProperty) { if (blobDataPropertyInfo.MessagePropertyAttribute.BlobType != BlobTypes.Data) { throw new Exception(string.Format("Blob Length Property {0} had {1} as its associated blob data property but {1} is not marked as a Blob Data field", currentPropertyInfo.PropertyInfo.Name, blobDataPropertyInfo.PropertyInfo.Name)); } string dataAssociatedBlobProperty = blobDataPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty; if (!string.IsNullOrEmpty(dataAssociatedBlobProperty) && dataAssociatedBlobProperty != currentPropertyInfo.PropertyInfo.Name) { throw new Exception(string.Format("Blob Length Property {0} had an explicit association with Blob Data Property {1} as its associated blob data but {1} has {2} as its associated length field", currentPropertyInfo.PropertyInfo.Name, blobDataPropertyInfo.PropertyInfo.Name, dataAssociatedBlobProperty)); } blobDataPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty = currentPropertyInfo.PropertyInfo.Name; break; } } if (string.IsNullOrEmpty(lengthAssociatedBlobProperty)) { throw new Exception(string.Format("Couldn't find the explicity specified associated blob data property for blob length field {0}", lengthAssociatedBlobProperty, currentPropertyInfo.PropertyInfo.Name)); } } } else if (currentBlobType == BlobTypes.Data) { // Since all length fields should be before their associated data fields an empty associated field here means something is wrong if (string.IsNullOrEmpty(currentPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty)) { throw new Exception(string.Format("Blob data property {0} has no associated length field", currentPropertyInfo.PropertyInfo.Name)); } // Now make sure the length field has the same association string blobDataAssociatedProperty = currentPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty; for (int blobDataIndex = 0; blobDataIndex < index; ++blobDataIndex) { MessageSerializedPropertyInfo blobLengthPropertyInfo = Properties[blobDataIndex]; if (blobLengthPropertyInfo.PropertyInfo.Name == blobDataAssociatedProperty) { if (blobLengthPropertyInfo.MessagePropertyAttribute.BlobType != BlobTypes.Length) { throw new Exception(string.Format("Blob Data Property {0} had {1} specified as its associated length property but {1} is not a blob length property", currentPropertyInfo.PropertyInfo.Name, blobDataAssociatedProperty)); } if (blobLengthPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty != currentPropertyInfo.PropertyInfo.Name) { throw new Exception(string.Format("Blob Data Property {0} had {1} specified as its associated length property but {1} has {2} specified as its associated blob data", currentPropertyInfo.PropertyInfo.Name, blobDataAssociatedProperty, blobLengthPropertyInfo.MessagePropertyAttribute.AssociatedBlobProperty)); } } } } } }