Operation

Namespace: Azure.Core
We found 10 examples in language CSharp for this search. You will see 31 fragments of code.

        #region IMergeableOperationCommand<Path> Members

        public override void Do(IArtContext context) { Apply(context, Operation, Indices, Nodes, Delta); }


		protected override void SetParent (object value, object parent)
		{
			((OperationMessage) value).SetParent ((Operation) parent);
		}


		void BuildInvokeParams (MessageProcessingContext mrc, out object [] parameters)
		{
			DispatchOperation operation = mrc.Operation;
			EnsureValid (operation);

			if (operation.DeserializeRequest) {
				parameters = operation.Invoker.AllocateInputs ();
				operation.Formatter.DeserializeRequest (mrc.IncomingMessage, parameters);
			} else
				parameters = new object [] { mrc.IncomingMessage };

			mrc.EventsHandler.BeforeInvoke (operation);
		}


	void BinaryAdd_2 (dynamic d, DynamicObjectMock mock)
	{
		mock.BinaryOperation = (binder, arg) => {
			Assert (binder.Operation, ExpressionType.Add, "Operation");
			AssertArgument (binder, new[] {
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null) },
				"ArgumentInfo");

			Assert (arg, null, "arg");
		};

		int? v = null;
		d = d + v;
	}

	void BinaryAdd_3 (dynamic d, DynamicObjectMock mock)
	{
		mock.BinaryOperation = (binder, arg) => {
			Assert (binder.Operation, ExpressionType.Add, "Operation");
			AssertArgument (binder, new[] {
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
			}, "ArgumentInfo");

			Assert (arg, Enum.A, "arg");
		};

		d = d + Enum.A;
	}

	void BinaryAdd_4 (dynamic d, DynamicObjectMock mock)
	{
		mock.BinaryOperation = (binder, arg) => {
			Assert (binder.Operation, ExpressionType.Add, "Operation");
			AssertArgument (binder, new[] {
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null) },
				"ArgumentInfo");

			Assert (arg, 7, "arg");
		};

		d = d + Tester.field;
	}

	void BinaryAddChecked_1 (dynamic d, DynamicObjectMock mock)
	{
		mock.BinaryOperation = (binder, arg) => {
			Assert (binder.Operation, ExpressionType.Add, "Operation");
			AssertArgument (binder, new[] {
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null) },
				"ArgumentInfo");

			Assert (arg, 3, "arg");
		};

		d = checked (d + 3);
	}

	void BinaryAddAssign_1 (dynamic d, DynamicObjectMock mock)
	{
		mock.BinaryOperation = (binder, arg) => {
			Assert (binder.Operation, ExpressionType.AddAssign, "Operation");
			AssertArgument (binder, new[] {
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
				"ArgumentInfo");

			Assert (arg, 1, "arg");
		};

		d += 1;
	}

	void BinaryAddAssignChecked_1 (dynamic d, DynamicObjectMock mock)
	{
		mock.BinaryOperation = (binder, arg) => {
			Assert (binder.Operation, ExpressionType.AddAssign, "Operation");
			AssertArgument (binder, new[] {
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
			    CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.Constant | CSharpArgumentInfoFlags.UseCompileTimeType, null) },
				"ArgumentInfo");

			Assert (arg, 1, "arg");
		};

		checked {
			d += 1;
		}
	}


		public Operation GetOperation (OperationDescription operation)
		{
			if (operation == null)
				throw new ArgumentNullException ("operation");
			foreach (Operation o in WsdlPortType.Operations)
				if (o.Name == operation.Name)
					return o;
			return null;
		}

		public OperationDescription GetOperationDescription (
			Operation operation)
		{
			if (operation == null)
				throw new ArgumentNullException ("operation");
			return Contract.Operations.FirstOrDefault (od => od.Name == operation.Name);
		}


		[SetUp]
		public void InitializeOperation()
		{
			// workaround for internal constructor
			Operation op = new Operation();
			operations = op.Messages;
		}


		protected override void SetParent (object value, object parent)
		{
			((OperationFault) value).SetParent ((Operation) parent);
		}


		#endregion // Properties

		#region Methods

		public int Add (Operation operation) 
		{
			Insert (Count, operation);
			return (Count - 1);
		}

		public bool Contains (Operation operation)
		{
			return List.Contains (operation);
		}

		public void CopyTo (Operation[] array, int index) 
		{
			List.CopyTo (array, index);
		}

		internal Operation Find (string name)
		{
			foreach (Operation op in List)
				if (op.Name == name)
					return op;
			return null;
		}

		public int IndexOf (Operation operation)
		{
			return List.IndexOf (operation);
		}

		public void Insert (int index, Operation operation)
		{
			List.Insert (index, operation);
		}

		public bool MoveNext()
		{
			return !IsDone();
		}

		public override bool Update()
		{
			if (!done && downloadIsDone)
			{
				FinishDownload();
				done = true;
			}

			return !done;
		}

		public override bool IsDone()
		{
			return done;
		}

		protected virtual bool WasBundleEncrypted()
		{
			if (AssetBundleManager.BundleEncryptionKey != "")
			{
				var encryptedAsset = bundle.LoadAsset<UMAEncryptedBundle>("EncryptedData");
				if (encryptedAsset)
				{
					byte[] decryptedData = new byte[0];
					try {
						decryptedData = EncryptionUtil.Decrypt(encryptedAsset.data, AssetBundleManager.BundleEncryptionKey, encryptedAsset.IV);
					}
					catch(System.Exception e)
					{
						Debug.LogError("[AssetBundleLoadOperation] could not decrypt " + assetBundleName+ "Error message was "+e.Message+" : "+e.StackTrace);
						return false;
					}
					bundle.Unload (true);
					decryptedLoadOperation = new AssetBundleLoadDecrypted(decryptedData, assetBundleName);
					return true;
				}
			}
			return false;
		}

		public override bool Update()
		{
			if (decryptedLoadOperation != null)
			{
				decryptedLoadOperation.Update();
				if (decryptedLoadOperation.IsDone())
				{
					assetBundle = decryptedLoadOperation.assetBundle;
					downloadProgress = 1f;
					m_WWW.Dispose();
					m_WWW = null;
					return false;
				}
				else //keep updating
				{
					downloadProgress = 0.9f + (decryptedLoadOperation.progress / 100);
					return true;
				}
			}
			else
			{
			base.Update();
			}
            
			// TODO: When can check iOS copy this into the iOS functions above
			// This checks that the download is actually happening and restarts it if it is not
			//fixes a bug in SimpleWebServer where it would randomly stop working for some reason
			if (!downloadIsDone)
			{
				downloadProgress = m_WWW.progress;
				if (!string.IsNullOrEmpty(m_WWW.error))
				{
					Debug.Log("[AssetBundleLoadOperation] download error for "+ m_WWW.url+" : " + m_WWW.error);
				}
				else
				{
					if (m_WWW.progress == 0)
					{
						zeroDownload++;
					}
#if UNITY_EDITOR
					//Sometimes SimpleWebServer randomly looses it port connection
					//Sometimes restarting the download helps, sometimes it needs to be completely restarted
					if (SimpleWebServer.Instance != null)
					{
						if (zeroDownload == 150)
						{
							Debug.Log("[AssetBundleLoadOperation] progress was zero for 150 frames restarting dowload");
							m_WWW.Dispose();//sometimes makes a difference when the download fails
							m_WWW = null;
							m_WWW = new WWW(m_Url);
						}

						if (zeroDownload == 300)//If we are in the editor we can restart the Server and this will make it work
						{
							Debug.LogWarning("[AssetBundleLoadOperation] progress was zero for 300 frames restarting the server");
							//we wont be able to do the following from a build
							int port = SimpleWebServer.Instance.Port;
							SimpleWebServer.Start(port);
							m_WWW.Dispose();
							m_WWW = null;
							m_WWW = new WWW(m_Url);
							zeroDownload = 0;
						}
					}
					else
#endif
					if(zeroDownload == 500)
					{
						Debug.Log("[AssetBundleLoadOperation] progress was zero for 500 frames restarting dowload");
						m_WWW.Dispose();
						m_WWW = null;
						m_WWW = new WWW(m_Url);
						zeroDownload = 0;
					}

				}
				return true;
			}
			else
			{
				downloadProgress = 1f;
				return false;
			}
		}

		protected override void FinishDownload()
		{
			error = m_WWW.error;
			if (!string.IsNullOrEmpty(error))
			{
				Debug.LogWarning("[AssetBundleLoadOperation.AssetBundleDownloadFromWebOperation] URL was "+ m_WWW.url+" error was " + error);
				return;
			}

			if (!m_isJsonIndex)
			{
				bundle = m_WWW.assetBundle;
				if (bundle == null)
				{
					Debug.LogWarning("[AssetBundleLoadOperation.AssetBundleDownloadFromWebOperation] "+assetBundleName+" was not a valid assetBundle");
					m_WWW.Dispose();
					m_WWW = null;
				}
				else if (!WasBundleEncrypted())
				{
					assetBundle = new LoadedAssetBundle(m_WWW.assetBundle);
					m_WWW.Dispose();
					m_WWW = null;
				}
			}
			else
			{
				string indexData = m_WWW.text;
				if (indexData == "")
				{
					Debug.LogWarning("[AssetBundleLoadOperation.AssetBundleDownloadFromWebOperation] The JSON AssetBundleIndex was empty");
				}
				else
				{
					assetBundle = new LoadedAssetBundle(m_WWW.text);
				}
				m_WWW.Dispose();
				m_WWW = null;
			}	
		}


        public virtual IQueryable<T> GetAll()
        {
            return _dbset;
        }

        public virtual RepositoryOperationResult Add(T entity)
        {
            if (entity == null)
            {
                return RepositoryOperationResult.NullEntity;
            }
            int countBefore;
            int countAfter;
            try
            {
                countBefore = _dbset.Count();
                if (_dbset.Add(entity) == null)
                {
                    throw new Exception("Add operation result is null");
                }
                countAfter = _dbset.Count();
            }
            catch (Exception ex)
            {
                _logger.ErrorException(string.Format("Error occured in Repository<{0}>.Add(entity)", typeof(T).ToString()), ex);
                return RepositoryOperationResult.UnknownError;
            }
            return countAfter > countBefore ? RepositoryOperationResult.Success : RepositoryOperationResult.EntityAlreadyExists;
        }

        public virtual RepositoryOperationResult Delete(T entity)
        {
            if (entity == null)
            {
                return RepositoryOperationResult.NullEntity;
            }
            try
            {
                if (_dbset.Remove(entity) != null)
                {
                    if (_context.SetEntryState(entity, EntityState.Deleted))
                    {
                        return RepositoryOperationResult.Success;
                    }
                    return RepositoryOperationResult.EntityNotFound;
                }
                else
                {
                    throw new Exception("Delete Operation result is null");
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorException(string.Format("Error occured in Repository<{0}>.Delete(entity)", typeof(T).ToString()), ex);
                return RepositoryOperationResult.UnknownError;
            }
        }

        public virtual RepositoryOperationResult DeleteAll(IEnumerable<T> entities)
        {
            if (entities == null)
            {
                return RepositoryOperationResult.NullEntity;
            }
            RepositoryOperationResult result = RepositoryOperationResult.Success;
            var itemsToDelete = entities.Count();
            for (int i = itemsToDelete - 1; i >= 0; i--)
            {
                var entity = entities.ToArray()[i];
                var singleResult = Delete(entity);
                if (singleResult != RepositoryOperationResult.Success
                    || result != RepositoryOperationResult.Success)
                {
                    result = RepositoryOperationResult.NotAllEntitiesProcessed;
                }
            }
            return result;
        }

        public virtual RepositoryOperationResult Update(T entity)
        {
            if (entity == null)
            {
                return RepositoryOperationResult.NullEntity;
            }
            try
            {
                try
                {
                    if (_dbset.Attach(entity) == null)
                    {
                        throw new Exception("Update operation resulted in Error");
                    }
                }
                catch (InvalidOperationException ex)
                {
                    _logger.ErrorException(string.Format("Item already in Repository<{0}> method Update(entity)", typeof(T).ToString()), ex);
                        var existingEntity = _context.GetAttached(entity);
                    if (existingEntity != null)
                    {
                        _context.Detach(existingEntity);
                        _dbset.Attach(entity);
                    }
                }
                if (_context.SetEntryState(entity, EntityState.Modified))
                {
                    return RepositoryOperationResult.Success;
                }
                return RepositoryOperationResult.EntityNotFound;
            }
            catch (Exception ex)
            {
                _logger.ErrorException(string.Format("Error occured in Repository<{0}>.Update(entity)", typeof(T).ToString()), ex);
                return RepositoryOperationResult.UnknownError;
            }
        }

        public virtual bool Any()
        {
            if (_dbset != null)
            {
                return _dbset.Any();
            }
            return false;
        }

Azure.Operation<T> : Object

Methods :

public abstract String get_Id()
public abstract T get_Value()
public abstract Response GetRawResponse()
public abstract Boolean get_HasCompleted()
public abstract Boolean get_HasValue()
public abstract ValueTask<Response<T>> WaitForCompletionAsync(CancellationToken cancellationToken = null)
public abstract ValueTask<Response<T>> WaitForCompletionAsync(TimeSpan pollingInterval = , CancellationToken cancellationToken = )
public abstract ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = null)
public abstract Response UpdateStatus(CancellationToken cancellationToken = null)
public Boolean Equals(Object obj = )
public Int32 GetHashCode()
public String ToString()
public Type GetType()