System.Type.ToString()

Here are the examples of the csharp api System.Type.ToString() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2253 Examples 7

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public Vector4 EditorGUILayoutVector4Field( string label, Vector4 value, params GUILayoutOption[] options )
		{
			Vector4 newValue = EditorGUILayout.Vector4Field( label, value, options );
			if ( newValue != value )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public int EditorGUILayoutIntSlider( GUIContent label, int value, int leftValue, int rightValue, params GUILayoutOption[] options )
		{
			int newValue = EditorGUILayout.IntSlider( label, value, leftValue, rightValue, options );
			if ( newValue != value )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public int EditorGUILayoutIntSlider( string label, int value, int leftValue, int rightValue, params GUILayoutOption[] options )
		{
			int newValue = EditorGUILayout.IntSlider( label, value, leftValue, rightValue, options );
			if ( newValue != value )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public Enum EditorGUILayoutEnumPopup( Enum selected, params GUILayoutOption[] options )
		{
			Enum newValue = EditorGUILayout.EnumPopup( selected, options );
			if ( !newValue.ToString().Equals( selected.ToString() ) )
			{
				UndoRecordObject( this, string.Concat( "Changing value EditorGUILayoutEnumPopup on node ", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
				//UndoRecordObject( this, string.Format( MessageFormat, "EditorGUILayoutEnumPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public int EditorGUILayoutIntPopup( string label, int selectedValue, string[] displayedOptions, int[] optionValues, params GUILayoutOption[] options )
		{
			int newValue = EditorGUILayout.IntPopup( label, selectedValue, displayedOptions, optionValues, options );
			if ( newValue != selectedValue )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public int EditorGUILayoutPopup( string label, int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options )
		{
			int newValue = EditorGUILayout.Popup( label, selectedIndex, displayedOptions, style, options );
			if ( newValue != selectedIndex )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public int EditorGUILayoutPopup( GUIContent label, int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options )
		{
			int newValue = EditorGUILayout.Popup( label, selectedIndex, displayedOptions, options );
			if ( newValue != selectedIndex )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public int EditorGUILayoutPopup( GUIContent label, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options )
		{
			int newValue = EditorGUILayout.Popup( label, selectedIndex, displayedOptions, style, options );
			if ( newValue != selectedIndex )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public int EditorGUILayoutPopup( int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options )
		{
			int newValue = EditorGUILayout.Popup( selectedIndex, displayedOptions, options );
			if ( newValue != selectedIndex )
			{
				UndoRecordObject( this, string.Format( MessageFormat, "EditorGUILayoutPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public int EditorGUILayoutPopup( string label, int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options )
		{
			int newValue = EditorGUILayout.Popup( label, selectedIndex, displayedOptions, options );
			if ( newValue != selectedIndex )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public bool EditorGUILayoutToggle( GUIContent label, bool value, params GUILayoutOption[] options )
		{
			bool newValue = EditorGUILayout.Toggle( label, value, options );
			if ( newValue != value )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public bool EditorGUILayoutToggle( string label, bool value, params GUILayoutOption[] options )
		{
			bool newValue = EditorGUILayout.Toggle( label, value, options );
			if ( newValue != value )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public bool EditorGUILayoutToggleLeft( string label, bool value, params GUILayoutOption[] options )
		{
			bool newValue = EditorGUILayout.ToggleLeft( label, value, options );
			if ( newValue != value )
			{
				UndoRecordObject( this, string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public bool EditorGUIToggle( Rect position, bool value )
		{
			bool newValue = EditorGUI.Toggle( position, value );
			if ( newValue != value )
			{
				UndoRecordObject( this, string.Format( MessageFormat, "EditorGUIToggle", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public string GUITextField( Rect position, string text, GUIStyle style )
		{
			string newValue = GUI.TextField( position, text, style );
			if ( !newValue.Equals( text ) )
			{
				UndoRecordObject( this, string.Format( MessageFormat, "GUITextfield", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public bool GUILayoutToggle( bool value, string text, GUIStyle style, params GUILayoutOption[] options )
		{
			bool newValue = GUILayout.Toggle( value, text, style, options );
			if ( newValue != value )
			{
				UndoRecordObject( this, string.Format( MessageFormat, "GUILayoutToggle", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return newValue;
		}

19 Source : UndoParentNode.cs
with GNU General Public License v3.0
from alexismorin

public bool GUILayoutButton( string text, GUIStyle style, params GUILayoutOption[] options )
		{
			bool value = GUILayout.Button( text, style, options );
			if ( value )
			{
				UndoRecordObject( this, string.Format( MessageFormat, "GUILayoutButton", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) );
			}
			return value;
		}

19 Source : CustomEditorGenerator.cs
with Apache License 2.0
from Algoryx

public static void Synchronize( bool regenerate = false )
    {
      // Newer versions replaces '.' with '+' so if our files
      // doesn't contains any '+' we regenerate all.
      {
        regenerate = regenerate ||
                     GetEditorFileInfos().FirstOrDefault( info => info.Name.StartsWith( "AGXUnity" ) &&
                                                                  !info.Name.Contains( '+' )
                                                        ) != null;

        if ( regenerate ) {
          Debug.Log( "Regenerating custom editors..." );
          foreach ( var info in GetEditorFileInfos() )
            DeleteFile( info );
        }
      }

      bool replacedetDatabaseDirty = false;

      // Removing editors which clreplacedes has been removed.
      {
        var replacedembly = GetAGXUnityreplacedembly();
        var editorreplacedembly = replacedembly.Load( Manager.AGXUnityEditorreplacedemblyName );
        foreach ( var info in GetEditorFileInfos() ) {
          var clreplacedName            = GetClreplacedName( info.Name );
          var type                 = replacedembly.GetType( clreplacedName, false );
          var editorClreplacedName      = "AGXUnityEditor.Editors." + GetClreplacedName( type ) + "Editor";
          var editorType           = editorreplacedembly.GetType( editorClreplacedName, false );
          var isEditorBaseMismatch = editorType != null && editorType.BaseType != typeof( InspectorEditor );
          if ( !IsMatch( type ) || isEditorBaseMismatch ) {
            Debug.Log( "Mismatching editor for clreplaced: " + clreplacedName + ", removing custom editor." );
            DeleteFile( info );
            replacedetDatabaseDirty = true;
          }
        }
      }

      // Generating missing editors.
      {
        var types = GetAGXUnityTypes();
        foreach ( var type in types ) {
          FileInfo info = new FileInfo( GetFilename( type, true ) );
          if ( !info.Exists ) {
            Debug.Log( "Custom editor for clreplaced " + type.ToString() + " is missing. Generating." );
            GenerateEditor( type, Path );
            replacedetDatabaseDirty = true;
          }
        }
      }

      if ( replacedetDatabaseDirty )
        replacedetDatabase.Refresh();
    }

19 Source : PrefabLoader.cs
with Apache License 2.0
from Algoryx

public static T Load<T>( string prefabName )
      where T : Object
    {
      T resource = Resources.Load<T>( prefabName );
      if ( resource == null )
        throw new Exception( "Unable to load resource: " + prefabName + " with type: " + typeof( T ).ToString() );

      return resource;
    }

19 Source : CustomEditorGenerator.cs
with Apache License 2.0
from Algoryx

private static string GetTypeFilename( Type type )
    {
      return type.ToString().Replace( ".", "+" );
    }

19 Source : CustomEditorGenerator.cs
with Apache License 2.0
from Algoryx

private static string GetClreplacedName( Type type )
    {
      return type.ToString().Replace( ".", string.Empty );
    }

19 Source : CustomEditorGenerator.cs
with Apache License 2.0
from Algoryx

private static void GenerateEditor( Type type, string path )
    {
      string clreplacedAndFilename = GetClreplacedName( type );
      string csFileContent = @"
using System;
using AGXUnity;
using AGXUnity.Collide;
using UnityEditor;

namespace AGXUnityEditor.Editors
{
  [CustomEditor( typeof( " + type.ToString() + @" ) )]
  [CanEditMultipleObjects]
  public clreplaced " + clreplacedAndFilename + @"Editor : InspectorEditor
  { }
}";
      File.WriteAllText( path + GetFilename( type, false ), csFileContent );
    }

19 Source : ExceptionExtensions.cs
with MIT License
from aljazsim

public static string Format(this Exception exception)
        {
            string message = string.Empty;

            while (exception != null)
            {
                message += exception.GetType().ToString() + ": " + exception.Message.Trim();
                message += Environment.NewLine;
                message += exception.StackTrace;
                message += Environment.NewLine;

                exception = exception.InnerException;
            }

            return message;
        }

19 Source : AttachStrategyEditor.cs
with MIT License
from all-iver

Transitioner SetTransitioner(int index, System.Type transitionerType, string replacedetName, 
                string propName) {
            DeleteChildreplacedetsWithName(replacedetName);
            if (transitionerType == null)
                return null;
            Transitioner newChild = (Transitioner) CreateInstance(transitionerType.ToString());
            newChild.Reset((AttachStrategy) target);
            newChild.hideFlags = HideFlags.HideInHierarchy;
            newChild.name = replacedetName;
            replacedetDatabase.AddObjectToreplacedet(newChild, serializedObject.targetObject);
            replacedetDatabase.Savereplacedets();
            replacedetDatabase.Refresh();
            SerializedProperty prop = serializedObject.FindProperty(propName);
            if (prop.arraySize < index + 1)
                prop.arraySize = index + 1;
            prop.GetArrayElementAtIndex(index).objectReferenceValue = newChild;
			serializedObject.ApplyModifiedProperties();
            return newChild;
        }

19 Source : FilesSelfTest.cs
with Apache License 2.0
from aloneguid

[Test]
      private async Task Rm_NullPath_ArgumentNullException()
      {
         try
         {
            await _storage.Rm(null);

            replacedertFail(typeof(ArgumentNullException).ToString(), "nothing");
         }
         catch(ArgumentNullException)
         {

         }
      }

19 Source : LoggingMock.cs
with MIT License
from altmann

public void Log<TContext>(ResultBase result)
        {
            LoggedContext = typeof(TContext).ToString();
            LoggedResult = result;
        }

19 Source : ResultLoggingTests.cs
with MIT License
from altmann

[Fact]
        public void LogOkResultWithTypedContext_EmptySuccess()
        {
            // Arrange
            var logger = new LoggingMock();
            Result.Setup(cfg => {
                cfg.Logger = logger;
            });

            // Act
            Result.Ok()
                .Log<Result>();

            // replacedert
            logger.LoggedContext.Should().Be(typeof(Result).ToString());
            logger.LoggedResult.Should().NotBeNull();
        }

19 Source : SyncProgressDialog.cs
with MIT License
from AlturosDestinations

public async Task Sync(AnnotationPackage[] packages)
        {
            this._syncing = true;

            try
            {
                foreach (var package in packages)
                {
                    package.User = Environment.UserName;
                }

                _ = Task.Run(() => this.UpdateProgressBar());
                await this._annotationPackageProvider.SyncPackagesAsync(packages);

                foreach (var package in packages)
                {
                    package.IsDirty = false;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Syncing failed! It's likely your changes have not been saved.\n\n" +
                    $"{exception.GetType().ToString()}\n\n" +
                    $"{exception.Message}", "Syncing error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this._syncing = false;
        }

19 Source : DiagnosticAnalyzer.cs
with GNU General Public License v3.0
from AminEsmaeily

public static CheckedException.Core.DiagnosticSeverity? GetAttributeParameterSeverity(SyntaxNodereplacedysisContext context, AttributeListSyntax attrib)
        {
            if (attrib.ChildNodes().Count() == 0)
                return null;

            IdentifierNameSyntax attributeType = null;
            if (attrib.ChildNodes().First().ChildNodes().FirstOrDefault() is QualifiedNameSyntax)
                attributeType = attrib.ChildNodes().First().ChildNodes().FirstOrDefault().DescendantNodes().OfType<IdentifierNameSyntax>().LastOrDefault();
            else
                attributeType = attrib.ChildNodes().First().DescendantNodes().OfType<IdentifierNameSyntax>().FirstOrDefault();

            if (attributeType == null)
                return null;

            var attributeInfo = context.SemanticModel.GetTypeInfo(attributeType);
            if (attributeInfo.Type == null)
                return null;

            if (attributeInfo.Type.ToString() != typeof(ThrowsExceptionAttribute).ToString())
                return null;

            var severity = attrib.Attributes.First().ArgumentList.DescendantNodes().OfType<MemberAccessExpressionSyntax>().FirstOrDefault();
            if (severity == null)
                return Core.DiagnosticSeverity.Error;

            var typeInfo = context.SemanticModel.GetTypeInfo(severity.Expression);
            if (typeInfo.Type == null || typeInfo.Type.ToString() != typeof(Core.DiagnosticSeverity).ToString())
                return null;

            Core.DiagnosticSeverity? result = null;
            foreach (var sev in Enum.GetValues(typeof(Core.DiagnosticSeverity)))
            {
                if (((Core.DiagnosticSeverity)sev).ToString().Equals(severity.Name.Identifier.Text))
                {
                    result = (Core.DiagnosticSeverity)sev;
                    break;
                }
            }

            return result;
        }

19 Source : DiagnosticAnalyzer.cs
with GNU General Public License v3.0
from AminEsmaeily

public static ITypeSymbol GetAttributeParameterType(SyntaxNodereplacedysisContext context, AttributeListSyntax attrib)
        {
            if (attrib.ChildNodes().Count() == 0)
                return null;

            IdentifierNameSyntax attributeType = null;
            if (attrib.ChildNodes().First().ChildNodes().FirstOrDefault() is QualifiedNameSyntax)
                attributeType = attrib.ChildNodes().First().ChildNodes().FirstOrDefault().DescendantNodes().OfType<IdentifierNameSyntax>().LastOrDefault();
            else
                attributeType = attrib.ChildNodes().First().DescendantNodes().OfType<IdentifierNameSyntax>().FirstOrDefault();

            if (attributeType == null)
                return null;

            var attributeInfo = context.SemanticModel.GetTypeInfo(attributeType);
            if (attributeInfo.Type == null)
                return null;

            if (attributeInfo.Type.ToString() != typeof(ThrowsExceptionAttribute).ToString())
                return null;

            var typeOf = attrib.Attributes.First().ArgumentList.DescendantNodes().OfType<TypeOfExpressionSyntax>().FirstOrDefault();
            if (typeOf == null)
                return null;

            IdentifierNameSyntax exceptionType = null;
            var qualifiedName = typeOf.DescendantNodes().OfType<QualifiedNameSyntax>().FirstOrDefault();
            if (qualifiedName == null)
                exceptionType = typeOf.DescendantNodes().OfType<IdentifierNameSyntax>().FirstOrDefault();
            else
                exceptionType = qualifiedName.DescendantNodes().OfType<IdentifierNameSyntax>().LastOrDefault();

            if (exceptionType == null)
                return null;

            var info = context.SemanticModel.GetTypeInfo(exceptionType);
            return info.Type;
        }

19 Source : DownloadUpdateDialog.cs
with MIT License
from Analogy-LogViewer

private void DownloadUpdateDialogLoad(object sender, EventArgs e)
        {
            _webClient = new MyWebClient
            {
                CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore)
            };

            if (Proxy != null)
            {
                _webClient.Proxy = Proxy;
            }

            var uri = new Uri(_downloadURL);


            if (BasicAuthDownload != null)
            {
                _webClient.Headers[HttpRequestHeader.Authorization] = BasicAuthDownload.ToString();
            }

            _webClient.DownloadProgressChanged += OnDownloadProgressChanged;

            _webClient.DownloadFileCompleted += WebClientOnDownloadFileCompleted;

            _webClient.DownloadFileAsync(uri, _tempFile);

            void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEventArgs asyncCompletedEventArgs)
            {
                if (asyncCompletedEventArgs.Cancelled)
                {
                    _taskCompletionSource.SetResult(false);
                    return;
                }

                UnzipZipFileIntoTempFolder(_tempFile, _targetFolder);
                if (asyncCompletedEventArgs.Error != null)
                {
                    XtraMessageBox.Show(asyncCompletedEventArgs.Error.Message,
                        asyncCompletedEventArgs.Error.GetType().ToString(), MessageBoxButtons.OK,
                        MessageBoxIcon.Error);

                }
                _webClient?.Dispose();
                DialogResult = DialogResult.OK;
                _taskCompletionSource.SetResult(true);
                Close();
            }


        }

19 Source : InspectorScript.cs
with GNU General Public License v3.0
from AndrasMumm

private string GetTypeString(GameObject obj)
        {
            string typeString = "";
            Queue<Type> toDo = new Queue<Type>();
            List<Type> result = new List<Type>();

            toDo.Enqueue(obj.GetType());
            while (toDo.Count > 0)
            {
                Type type = toDo.Dequeue();
                List<Type> dTypes = new List<Type>();
                if (derivedTypes.TryGetValue(type, out dTypes))
                {
                    foreach (Type t in dTypes)
                    {
                        if (!result.Contains(t))
                        {
                            toDo.Enqueue(t);
                            result.Add(t);
                        }
                    }
                }
            }

            foreach (Type t in result)
            {
                if (typeString != "") typeString += "=>";
                typeString += t.ToString();
            }

            return typeString;
        }

19 Source : ApplicationManager.cs
with GNU General Public License v3.0
from AndreiFedarets

public static IApplicationBase RunInplace(Guid sessionUid, bool processOnwer)
            {
                IApplicationBase application = null;
                if (processOnwer)
                {
                    application = new ProfilingApplication(sessionUid, processOnwer);
                    application.Run();
                }
                else
                {
                    AppDomain appDomain = AppDomain.CurrentDomain.Clone(typeof(ProfilingApplication).ToString(), typeof(ApplicationManager).GetreplacedemblyPath());
                    appDomain.InvokeStaticMember(typeof(ApplicationManager), "Initialize", BindingFlags.InvokeMethod | BindingFlags.Public, null);
                    ChronosApplicationLauncher<ProfilingApplication> activator = RemoteActivator.CreateInstance<ChronosApplicationLauncher<ProfilingApplication>>(appDomain);
                    activator.Run(sessionUid, processOnwer);
                    application = (IApplicationBase)activator.GetApplication();
                }
                return application;
            }

19 Source : WeakApplication.cs
with GNU General Public License v3.0
from AndreiFedarets

public string Ping(string message)
        {
            IApplication application;
            if (VerifyDaemonLaunched(false, out application))
            {
                return application.Ping(message);
            }
            return message == null ? GetType().ToString() : message + GetType();
        }

19 Source : ApplicationManager.cs
with GNU General Public License v3.0
from AndreiFedarets

public static IApplication RunInplace(bool processOnwer, Guid sessionUid)
        {
            IApplication application;
            if (processOnwer)
            {
                application = new Application(true, sessionUid);
                application.Run();
            }
            else
            {
                AppDomain appDomain = AppDomain.CurrentDomain.Clone(typeof(Application).ToString(), typeof(ApplicationManager).GetreplacedemblyPath());
                ChronosApplicationLauncher<Application> activator = RemoteActivator.CreateInstance<ChronosApplicationLauncher<Application>>(appDomain);
                activator.Run(false, sessionUid);
                application = ConnectLocal(sessionUid);
            }
            return application;
        }

19 Source : InplaceApplicationManager.cs
with GNU General Public License v3.0
from AndreiFedarets

public void Run(params object[] args)
        {
            _appDomain = AppDomain.CurrentDomain.Clone(typeof(T).ToString(), GetType().GetreplacedemblyPath());
            _activator = RemoteActivator.CreateInstance<ChronosApplicationLauncher<T>>(_appDomain);
            _activator.Run(args);
        }

19 Source : DisposableTracker.cs
with GNU General Public License v3.0
from AndreiFedarets

public override string ToString()
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("Resource Type: {0}", _disposable.GetType().ToString());
            builder.AppendLine();
            builder.AppendFormat("Created StackTrace: {0}{1}", Environment.NewLine, _createdStackTrace);
            builder.AppendLine();
            builder.AppendFormat("Disposed StackTrace: {0}{1}", Environment.NewLine, _disposedStackTrace);
            builder.AppendLine();
            return builder.ToString();
        }

19 Source : ApplicationManager.cs
with GNU General Public License v3.0
from AndreiFedarets

public static IApplicationBase RunInplace(bool processOnwer)
            {
                IApplicationBase application;
                if (processOnwer)
                {
                    application = new MainApplication(processOnwer);
                    application.Run();
                }
                else
                {
                    AppDomain appDomain = AppDomain.CurrentDomain.Clone(typeof(MainApplication).ToString(), typeof(ApplicationManager).GetreplacedemblyPath());
                    ChronosApplicationLauncher<MainApplication> activator = RemoteActivator.CreateInstance<ChronosApplicationLauncher<MainApplication>>(appDomain);
                    activator.Run(processOnwer);
                    application = (IApplicationBase)activator.GetApplication();
                }
                return application;
            }

19 Source : CrmWorkflowBase.cs
with MIT License
from AndrewButenko

public string SerializeDictionary(Dictionary<string, object> dictionary)
        {
            var rootElement = new XElement("Request");

            foreach (var key in dictionary.Keys)
            {
                var childElement = new XElement(key);

                var value = dictionary[key];

                if (value == null)
                {
                    var isnullAttribute = new XAttribute("IsNull", true);
                    childElement.Add(isnullAttribute);
                }
                else
                {
                    var typeName = value.GetType().ToString();

                    var typeAttribute = new XAttribute("Type", typeName);
                    childElement.Add(typeAttribute);

                    switch (typeName)
                    {
                        case "System.Boolean":
                        case "System.String":
                        case "System.Int32":
                        case "System.DateTime":
                        case "System.Decimal":
                            childElement.SetValue(value);
                            break;
                        case "Microsoft.Xrm.Sdk.OptionSetValue":
                            childElement.SetValue(((OptionSetValue)value).Value);
                            break;
                        case "Microsoft.Xrm.Sdk.Money":
                            childElement.SetValue(((Money)value).Value);
                            break;
                        case "Microsoft.Xrm.Sdk.EnreplacedyReference":
                            var enreplacedyReference = (EnreplacedyReference)value;
                            childElement.Add(new XElement("Id", enreplacedyReference.Id));
                            childElement.Add(new XElement("LogicalName", enreplacedyReference.LogicalName));
                            break;
                        default:
                            throw new InvalidPluginExecutionException($"Serialization is not implemented for {typeName} clreplaced");
                    }
                }

                rootElement.Add(childElement);
            }

            return rootElement.ToString();
        }

19 Source : ShutdownEventCatcher.cs
with MIT License
from andruzzzhka

static void RaiseShutdownEvent(ShutdownEventArgs args)
        {
            foreach(var action in Shutdown.GetInvocationList())
            {
                try
                {
                    action.DynamicInvoke(args);
                }
                catch (Exception e)
                {
                    Logger.Instance.Warning($"Exception on Shutdown event in {action.Target.GetType().ToString()}.{action.Method.Name}: {e}");
                }
            }
        }

19 Source : ChunkedRequestStream.cs
with MIT License
from andruzzzhka

public override IAsyncResult BeginRead (
      byte[] buffer, int offset, int count, AsyncCallback callback, object state)
    {
      if (_disposed)
        throw new ObjectDisposedException (GetType ().ToString ());

      if (buffer == null)
        throw new ArgumentNullException ("buffer");

      if (offset < 0)
        throw new ArgumentOutOfRangeException ("offset", "A negative value.");

      if (count < 0)
        throw new ArgumentOutOfRangeException ("count", "A negative value.");

      var len = buffer.Length;
      if (offset + count > len)
        throw new ArgumentException (
          "The sum of 'offset' and 'count' is greater than 'buffer' length.");

      var ares = new HttpStreamAsyncResult (callback, state);
      if (_noMoreData) {
        ares.Complete ();
        return ares;
      }

      var nread = _decoder.Read (buffer, offset, count);
      offset += nread;
      count -= nread;
      if (count == 0) {
        // Got all we wanted, no need to bother the decoder yet.
        ares.Count = nread;
        ares.Complete ();

        return ares;
      }

      if (!_decoder.WantMore) {
        _noMoreData = nread == 0;
        ares.Count = nread;
        ares.Complete ();

        return ares;
      }

      ares.Buffer = new byte[_bufferLength];
      ares.Offset = 0;
      ares.Count = _bufferLength;

      var rstate = new ReadBufferState (buffer, offset, count, ares);
      rstate.InitialCount += nread;
      base.BeginRead (ares.Buffer, ares.Offset, ares.Count, onRead, rstate);

      return ares;
    }

19 Source : ChunkedRequestStream.cs
with MIT License
from andruzzzhka

public override int EndRead (IAsyncResult asyncResult)
    {
      if (_disposed)
        throw new ObjectDisposedException (GetType ().ToString ());

      if (asyncResult == null)
        throw new ArgumentNullException ("asyncResult");

      var ares = asyncResult as HttpStreamAsyncResult;
      if (ares == null)
        throw new ArgumentException ("A wrong IAsyncResult.", "asyncResult");

      if (!ares.IsCompleted)
        ares.AsyncWaitHandle.WaitOne ();

      if (ares.HasException)
        throw new HttpListenerException (400, "I/O operation aborted.");

      return ares.Count;
    }

19 Source : HttpListener.cs
with MIT License
from andruzzzhka

internal void CheckDisposed ()
    {
      if (_disposed)
        throw new ObjectDisposedException (GetType ().ToString ());
    }

19 Source : RequestStream.cs
with MIT License
from andruzzzhka

public override IAsyncResult BeginRead (
      byte[] buffer, int offset, int count, AsyncCallback callback, object state)
    {
      if (_disposed)
        throw new ObjectDisposedException (GetType ().ToString ());

      var nread = fillFromBuffer (buffer, offset, count);
      if (nread > 0 || nread == -1) {
        var ares = new HttpStreamAsyncResult (callback, state);
        ares.Buffer = buffer;
        ares.Offset = offset;
        ares.Count = count;
        ares.SyncRead = nread > 0 ? nread : 0;
        ares.Complete ();

        return ares;
      }

      // Avoid reading past the end of the request to allow for HTTP pipelining.
      if (_bodyLeft >= 0 && count > _bodyLeft)
        count = (int) _bodyLeft;

      return _stream.BeginRead (buffer, offset, count, callback, state);
    }

19 Source : RequestStream.cs
with MIT License
from andruzzzhka

public override int EndRead (IAsyncResult asyncResult)
    {
      if (_disposed)
        throw new ObjectDisposedException (GetType ().ToString ());

      if (asyncResult == null)
        throw new ArgumentNullException ("asyncResult");

      if (asyncResult is HttpStreamAsyncResult) {
        var ares = (HttpStreamAsyncResult) asyncResult;
        if (!ares.IsCompleted)
          ares.AsyncWaitHandle.WaitOne ();

        return ares.SyncRead;
      }

      // Close on exception?
      var nread = _stream.EndRead (asyncResult);
      if (nread > 0 && _bodyLeft > 0)
        _bodyLeft -= nread;

      return nread;
    }

19 Source : RequestStream.cs
with MIT License
from andruzzzhka

public override int Read (byte[] buffer, int offset, int count)
    {
      if (_disposed)
        throw new ObjectDisposedException (GetType ().ToString ());

      // Call the fillFromBuffer method to check for buffer boundaries even when _bodyLeft is 0.
      var nread = fillFromBuffer (buffer, offset, count);
      if (nread == -1) // No more bytes available (Content-Length).
        return 0;

      if (nread > 0)
        return nread;

      nread = _stream.Read (buffer, offset, count);
      if (nread > 0 && _bodyLeft > 0)
        _bodyLeft -= nread;

      return nread;
    }

19 Source : ResponseStream.cs
with MIT License
from andruzzzhka

public override IAsyncResult BeginWrite (
      byte[] buffer, int offset, int count, AsyncCallback callback, object state)
    {
      if (_disposed)
        throw new ObjectDisposedException (GetType ().ToString ());

      return _body.BeginWrite (buffer, offset, count, callback, state);
    }

19 Source : HttpListener.cs
with MIT License
from andruzzzhka

private void close (bool force)
    {
      if (_listening) {
        _listening = false;
        EndPointManager.RemoveListener (this);
      }

      lock (_ctxRegistrySync)
        cleanupContextQueue (!force);

      cleanupContextRegistry ();
      cleanupConnections ();
      cleanupWaitQueue (new ObjectDisposedException (GetType ().ToString ()));

      _disposed = true;
    }

19 Source : ResponseStream.cs
with MIT License
from andruzzzhka

public override void EndWrite (IAsyncResult asyncResult)
    {
      if (_disposed)
        throw new ObjectDisposedException (GetType ().ToString ());

      _body.EndWrite (asyncResult);
    }

19 Source : ResponseStream.cs
with MIT License
from andruzzzhka

public override void Write (byte[] buffer, int offset, int count)
    {
      if (_disposed)
        throw new ObjectDisposedException (GetType ().ToString ());

      _body.Write (buffer, offset, count);
    }

See More Examples