Esempio n. 1
0
        private static string GetResourceString(ExceptionResource argument)
        {
            Debug.Assert(Enum.IsDefined(typeof(ExceptionResource), argument),
                "The enum value is not defined, please check the ExceptionResource Enum.");

            // Should be look up with enviorment resources
            string resourceString = null;
            switch (argument)
            {
                case ExceptionResource.AlreadyProducing:
                    resourceString = "Already producing.";
                    break;
                case ExceptionResource.NotProducingNoAlloc:
                    resourceString = "No ongoing producing operation. Make sure Alloc() was called.";
                    break;
                case ExceptionResource.NotProducingToComplete:
                    resourceString = "No ongoing producing operation to complete.";
                    break;
                case ExceptionResource.AlreadyConsuming:
                    resourceString = "Already consuming.";
                    break;
                case ExceptionResource.NotConsumingToComplete:
                    resourceString = "No ongoing consuming operation to complete.";
                    break;
                case ExceptionResource.NoConcurrentReads:
                    resourceString = "Concurrent reads are not supported.";
                    break;
                case ExceptionResource.GetResultNotCompleted:
                    resourceString = "can't GetResult unless completed";
                    break;

            }
            return resourceString ?? $"Error ResourceKey not defined {argument}.";
        }
Esempio n. 2
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public LdapException(string message, Exception innerException)
     : base(message, innerException)
 {
     if (message != null && message.IndexOf(" ") > -1)
     {
         m_expRes = new ExceptionResource();
         m_expRes.Message = message;
         m_expRes.Description = message;
     }
     else
         m_expRes = new ExceptionResource(message, "Workshare.DirectorySearcher.Exceptions", typeof(LdapException).Assembly);
 }
        public void Test_01_GetException()
        {
            string err = "This is a test exception resource";
            string desc = "This is a test message";
            int num = 10000;
            string resid = "TEST";

            ExceptionResource er = new ExceptionResource(resid, "Workshare.DirectorySearcher.Tests.Exceptions", typeof(Test_ExceptionResource).Assembly);
            Assert.AreEqual(err, er.Message, "The error message are different");
            Assert.AreEqual(desc, er.Description, "The descriptions are different");
            Assert.AreEqual(num, er.ErrorNumber, "The error numbers are different");
            Assert.AreEqual(resid, er.Id, "The resource ids are different");
        }
Esempio n. 4
0
 internal static void ThrowArgumentNullException(ExceptionResource resource)
 {
     throw new ArgumentNullException(Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 5
0
 private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
 {
     return(new ArgumentOutOfRangeException(GetArgumentName(argument), GetResourceString(resource)));
 }
Esempio n. 6
0
    /// <summary>
    /// Converts an <see cref="ExceptionResource"/> enum value to the resource string.
    /// </summary>
    /// <param name="resource">The <see cref="ExceptionResource"/> to convert</param>
    /// <returns>A string representation of the specified <see cref="ExceptionResource"/></returns>
    internal static string GetResourceByName(ExceptionResource resource) {
      switch (resource) {
        case ExceptionResource.Argument_AddingDuplicate:
          return StringResources.Argument_AddingDuplicate;

        case ExceptionResource.Arg_ArrayPlusOffTooSmall:
          return StringResources.Arg_ArrayPlusOffTooSmall;

        case ExceptionResource.Argument_Empty:
          return StringResources.Argument_Empty;

        case ExceptionResource.ArgumentOutOfRange_Index:
          return StringResources.ArgumentOutOfRange_Index;

        case ExceptionResource.Argument_InvalidOfLen:
          return StringResources.Argument_InvalidOfLen;

        default:
          Debug.Assert(false,
            "The enum value is not defined, please checked ExceptionArgumentName Enum");
          return string.Empty;
      }
    }
Esempio n. 7
0
 internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, int paramNumber, ExceptionResource resource)
 {
     throw new ArgumentOutOfRangeException(GetArgumentName(argument) + "[" + paramNumber.ToString() + "]",
                                           Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 8
0
        internal static string GetResourceName(ExceptionResource resource)
        {
            switch (resource)
            {
                case ExceptionResource.Argument_ImplementIComparable:
                    return "Argument_ImplementIComparable";

                case ExceptionResource.Argument_InvalidType:
                    return "Argument_InvalidType";

                case ExceptionResource.Argument_InvalidArgumentForComparison:
                    return "Argument_InvalidArgumentForComparison";

                case ExceptionResource.Argument_InvalidRegistryKeyPermissionCheck:
                    return "Argument_InvalidRegistryKeyPermissionCheck";

                case ExceptionResource.ArgumentOutOfRange_NeedNonNegNum:
                    return "ArgumentOutOfRange_NeedNonNegNum";

                case ExceptionResource.Arg_ArrayPlusOffTooSmall:
                    return "Arg_ArrayPlusOffTooSmall";

                case ExceptionResource.Arg_NonZeroLowerBound:
                    return "Arg_NonZeroLowerBound";

                case ExceptionResource.Arg_RankMultiDimNotSupported:
                    return "Arg_RankMultiDimNotSupported";

                case ExceptionResource.Arg_RegKeyDelHive:
                    return "Arg_RegKeyDelHive";

                case ExceptionResource.Arg_RegKeyStrLenBug:
                    return "Arg_RegKeyStrLenBug";

                case ExceptionResource.Arg_RegSetStrArrNull:
                    return "Arg_RegSetStrArrNull";

                case ExceptionResource.Arg_RegSetMismatchedKind:
                    return "Arg_RegSetMismatchedKind";

                case ExceptionResource.Arg_RegSubKeyAbsent:
                    return "Arg_RegSubKeyAbsent";

                case ExceptionResource.Arg_RegSubKeyValueAbsent:
                    return "Arg_RegSubKeyValueAbsent";

                case ExceptionResource.Argument_AddingDuplicate:
                    return "Argument_AddingDuplicate";

                case ExceptionResource.Serialization_InvalidOnDeser:
                    return "Serialization_InvalidOnDeser";

                case ExceptionResource.Serialization_MissingKeyValuePairs:
                    return "Serialization_MissingKeyValuePairs";

                case ExceptionResource.Serialization_NullKey:
                    return "Serialization_NullKey";

                case ExceptionResource.Argument_InvalidArrayType:
                    return "Argument_InvalidArrayType";

                case ExceptionResource.NotSupported_KeyCollectionSet:
                    return "NotSupported_KeyCollectionSet";

                case ExceptionResource.NotSupported_ValueCollectionSet:
                    return "NotSupported_ValueCollectionSet";

                case ExceptionResource.ArgumentOutOfRange_SmallCapacity:
                    return "ArgumentOutOfRange_SmallCapacity";

                case ExceptionResource.ArgumentOutOfRange_Index:
                    return "ArgumentOutOfRange_Index";

                case ExceptionResource.Argument_InvalidOffLen:
                    return "Argument_InvalidOffLen";

                case ExceptionResource.Argument_ItemNotExist:
                    return "Argument_ItemNotExist";

                case ExceptionResource.ArgumentOutOfRange_Count:
                    return "ArgumentOutOfRange_Count";

                case ExceptionResource.ArgumentOutOfRange_InvalidThreshold:
                    return "ArgumentOutOfRange_InvalidThreshold";

                case ExceptionResource.ArgumentOutOfRange_ListInsert:
                    return "ArgumentOutOfRange_ListInsert";

                case ExceptionResource.NotSupported_ReadOnlyCollection:
                    return "NotSupported_ReadOnlyCollection";

                case ExceptionResource.InvalidOperation_CannotRemoveFromStackOrQueue:
                    return "InvalidOperation_CannotRemoveFromStackOrQueue";

                case ExceptionResource.InvalidOperation_EmptyQueue:
                    return "InvalidOperation_EmptyQueue";

                case ExceptionResource.InvalidOperation_EnumOpCantHappen:
                    return "InvalidOperation_EnumOpCantHappen";

                case ExceptionResource.InvalidOperation_EnumFailedVersion:
                    return "InvalidOperation_EnumFailedVersion";

                case ExceptionResource.InvalidOperation_EmptyStack:
                    return "InvalidOperation_EmptyStack";

                case ExceptionResource.ArgumentOutOfRange_BiggerThanCollection:
                    return "ArgumentOutOfRange_BiggerThanCollection";

                case ExceptionResource.InvalidOperation_EnumNotStarted:
                    return "InvalidOperation_EnumNotStarted";

                case ExceptionResource.InvalidOperation_EnumEnded:
                    return "InvalidOperation_EnumEnded";

                case ExceptionResource.NotSupported_SortedListNestedWrite:
                    return "NotSupported_SortedListNestedWrite";

                case ExceptionResource.InvalidOperation_NoValue:
                    return "InvalidOperation_NoValue";

                case ExceptionResource.InvalidOperation_RegRemoveSubKey:
                    return "InvalidOperation_RegRemoveSubKey";

                case ExceptionResource.Security_RegistryPermission:
                    return "Security_RegistryPermission";

                case ExceptionResource.UnauthorizedAccess_RegistryNoWrite:
                    return "UnauthorizedAccess_RegistryNoWrite";

                case ExceptionResource.ObjectDisposed_RegKeyClosed:
                    return "ObjectDisposed_RegKeyClosed";

                case ExceptionResource.NotSupported_InComparableType:
                    return "NotSupported_InComparableType";
            }
            return string.Empty;
        }
 internal static void ThrowSerializationException(ExceptionResource resource) {
     throw new SerializationException(SR.GetString(GetResourceName(resource)));
 }
Esempio n. 10
0
        private static string GetResource(ExceptionResource resource)
        {
            switch (resource)
            {
                case ExceptionResource.Argument_InValidForm:
                    return "The Argument \"{0}\" is in Invalid Form.";
                case ExceptionResource.Argument_AlreadyInDictionary:
                    return "The Argument \"{0}\" is already in dictionary.";
                case ExceptionResource.Argument_TokenPartAlreadyInDictionary:
                    return "A Part or the whole of the argument \"{0}\" is already in dictionary.";
                case ExceptionResource.MoreThenOneRegularExpression:
                    return "Option with RegularExpressionValidator and Same Token Exist already.";
                case ExceptionResource.DoubleStaticValue:
                    return "Option with same token and same StaticValue exist already.";
                case ExceptionResource.Maximumoccurenceminimum:
                    return "Value can not be less then 1.";

            }
            return string.Empty;
        }
Esempio n. 11
0
 internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
 {
     throw new ArgumentOutOfRangeException(GetArgumentName(argument), Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 12
0
 private static InvalidOperationException GetInvalidOperationException(ExceptionResource resource)
 {
     return(new InvalidOperationException(GetResourceString(resource)));
 }
Esempio n. 13
0
 /// <summary>
 /// Used for serialising across boundaries etc
 /// </summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 protected LdapException(SerializationInfo info, StreamingContext context)
     :base(info, context)
 {
     if ( info != null )
         m_expRes = info.GetValue("ExcpResource", typeof(ExceptionResource)) as ExceptionResource;
 }
Esempio n. 14
0
 private static ArgumentException GetArgumentException(ExceptionResource resource)
 {
     return(new ArgumentException(GetResourceString(resource)));
 }
Esempio n. 15
0
 internal static void ThrowObjectDisposedException(ExceptionResource resource)
 {
     throw new ObjectDisposedException(null, GetResourceString(resource));
 }
Esempio n. 16
0
 internal static void ThrowUnauthorizedAccessException(ExceptionResource resource)
 {
     throw new UnauthorizedAccessException(GetResourceString(resource));
 }
Esempio n. 17
0
 internal static void ThrowNotSupportedException(ExceptionResource resource)
 {
     throw new NotSupportedException(GetResourceString(resource));
 }
Esempio n. 18
0
 internal static void ThrowRankException(ExceptionResource resource)
 {
     throw new RankException(GetResourceString(resource));
 }
Esempio n. 19
0
 //internal static void ThrowArgumentException(ExceptionResource resource, ExceptionArgument argument, string value)
 //{
 //    throw new ArgumentException(string.Format(GetResource(resource), GetArgumentName(argument), value), GetArgumentName(argument));
 //}
 //internal static void ThrowArgumentException(ExceptionResource resource, string value)
 //{
 //    throw new ArgumentException(string.Format(GetResource(resource), value));
 //}
 internal static void ThrowArgumentException(ExceptionResource resource, ExceptionArgument argument)
 {
     throw new ArgumentException(string.Format(GetResource(resource), GetArgumentName(argument)), GetArgumentName(argument));
 }
Esempio n. 20
0
 private static ArgumentException GetArgumentException(ExceptionResource resource, ExceptionArgument argument)
 {
     return(new ArgumentException(GetResourceString(resource), GetArgumentName(argument)));
 }
Esempio n. 21
0
        public DirectoryEntry GetEntry(AuthenticationTypes type)
        {
            DirectoryEntry entry = null;
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(ResourceManager.GetString("CONN_START",
                            "Workshare.DirectorySearcher.Exceptions", typeof(LdapServerInformation).Assembly), ConnectionString);
                Logger.LogInfo(sb.ToString());

                if (UserName.Length == 0 && type == AuthenticationTypes.None)
                {
                    entry = new DirectoryEntry(ConnectionString);
                }
                else
                {
                    if (type == AuthenticationTypes.None)
                        entry = new DirectoryEntry(ConnectionString, UserName, Password); 
                    else
                        entry = new DirectoryEntry(ConnectionString, UserName, Password, type);
                }
                // Do this to force the communication between us and the LDAP server.
                string name = entry.Name;
                sb.Remove(0, sb.Length);
                
                sb.AppendFormat(m_connectionMessage, name);
				Logger.LogInfo(sb.ToString());
                if (LdapType == EngineType.NotSet ) 
                {
                    WorkoutDefaultName(entry);
                    WorkoutEngineType(entry);
                }
            }
            catch (COMException e)
            {
                // Check if we need to use anonymous connection (Domino server what us to!)
                if ((uint)e.ErrorCode != 0x80072027)
                {
					if (entry != null)
					{
						entry.Dispose();
					}
                	// A different type of exception so we better report it.
                    sb.Remove(0, sb.Length);
                    ExceptionResource er = new ExceptionResource("LDAPACCESS", "Workshare.DirectorySearcher.Exceptions", typeof(LdapServerInformation).Assembly);
                    sb.AppendFormat(er.Description, Environment.NewLine, e.Message, ConnectionString);
                    er.Description = sb.ToString();
					Logger.LogInfo(sb.ToString());
                    throw (new InvalidOperationException(sb.ToString(), e));
                }
                else
                {
                    sb.AppendFormat(ResourceManager.GetString("CONN_FAIL1",
                            "Workshare.DirectorySearcher.Exceptions", typeof(LdapServerInformation).Assembly), Environment.NewLine, e.Message);
                    // We need to use anonymous connection (Domino server what us to!)
                    if (entry != null)
                        entry.Dispose();
                    entry = GetEntry(AuthenticationTypes.Anonymous);
                }
            }
            return entry;
        }
Esempio n. 22
0
 private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument, int paramNumber, ExceptionResource resource)
 {
     return(new ArgumentOutOfRangeException(GetArgumentName(argument) + "[" + paramNumber.ToString() + "]", GetResourceString(resource)));
 }
Esempio n. 23
0
 internal static void ThrowSecurityException(ExceptionResource resource)
 {
     throw new SecurityException(Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 24
0
        private static string GetResourceString(ExceptionResource resource)
        {
            switch (resource)
            {
            case ExceptionResource.ArgumentOutOfRange_Index:
                return(SR.ArgumentOutOfRange_Index);

            case ExceptionResource.ArgumentOutOfRange_IndexCount:
                return(SR.ArgumentOutOfRange_IndexCount);

            case ExceptionResource.ArgumentOutOfRange_IndexCountBuffer:
                return(SR.ArgumentOutOfRange_IndexCountBuffer);

            case ExceptionResource.ArgumentOutOfRange_Count:
                return(SR.ArgumentOutOfRange_Count);

            case ExceptionResource.ArgumentOutOfRange_Year:
                return(SR.ArgumentOutOfRange_Year);

            case ExceptionResource.Arg_ArrayPlusOffTooSmall:
                return(SR.Arg_ArrayPlusOffTooSmall);

            case ExceptionResource.NotSupported_ReadOnlyCollection:
                return(SR.NotSupported_ReadOnlyCollection);

            case ExceptionResource.Arg_RankMultiDimNotSupported:
                return(SR.Arg_RankMultiDimNotSupported);

            case ExceptionResource.Arg_NonZeroLowerBound:
                return(SR.Arg_NonZeroLowerBound);

            case ExceptionResource.ArgumentOutOfRange_GetCharCountOverflow:
                return(SR.ArgumentOutOfRange_GetCharCountOverflow);

            case ExceptionResource.ArgumentOutOfRange_ListInsert:
                return(SR.ArgumentOutOfRange_ListInsert);

            case ExceptionResource.ArgumentOutOfRange_NeedNonNegNum:
                return(SR.ArgumentOutOfRange_NeedNonNegNum);

            case ExceptionResource.ArgumentOutOfRange_SmallCapacity:
                return(SR.ArgumentOutOfRange_SmallCapacity);

            case ExceptionResource.Argument_InvalidOffLen:
                return(SR.Argument_InvalidOffLen);

            case ExceptionResource.Argument_CannotExtractScalar:
                return(SR.Argument_CannotExtractScalar);

            case ExceptionResource.ArgumentOutOfRange_BiggerThanCollection:
                return(SR.ArgumentOutOfRange_BiggerThanCollection);

            case ExceptionResource.Serialization_MissingKeys:
                return(SR.Serialization_MissingKeys);

            case ExceptionResource.Serialization_NullKey:
                return(SR.Serialization_NullKey);

            case ExceptionResource.NotSupported_KeyCollectionSet:
                return(SR.NotSupported_KeyCollectionSet);

            case ExceptionResource.NotSupported_ValueCollectionSet:
                return(SR.NotSupported_ValueCollectionSet);

            case ExceptionResource.InvalidOperation_NullArray:
                return(SR.InvalidOperation_NullArray);

            case ExceptionResource.TaskT_TransitionToFinal_AlreadyCompleted:
                return(SR.TaskT_TransitionToFinal_AlreadyCompleted);

            case ExceptionResource.TaskCompletionSourceT_TrySetException_NullException:
                return(SR.TaskCompletionSourceT_TrySetException_NullException);

            case ExceptionResource.TaskCompletionSourceT_TrySetException_NoExceptions:
                return(SR.TaskCompletionSourceT_TrySetException_NoExceptions);

            case ExceptionResource.NotSupported_StringComparison:
                return(SR.NotSupported_StringComparison);

            case ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported:
                return(SR.ConcurrentCollection_SyncRoot_NotSupported);

            case ExceptionResource.Task_MultiTaskContinuation_NullTask:
                return(SR.Task_MultiTaskContinuation_NullTask);

            case ExceptionResource.InvalidOperation_WrongAsyncResultOrEndCalledMultiple:
                return(SR.InvalidOperation_WrongAsyncResultOrEndCalledMultiple);

            case ExceptionResource.Task_MultiTaskContinuation_EmptyTaskList:
                return(SR.Task_MultiTaskContinuation_EmptyTaskList);

            case ExceptionResource.Task_Start_TaskCompleted:
                return(SR.Task_Start_TaskCompleted);

            case ExceptionResource.Task_Start_Promise:
                return(SR.Task_Start_Promise);

            case ExceptionResource.Task_Start_ContinuationTask:
                return(SR.Task_Start_ContinuationTask);

            case ExceptionResource.Task_Start_AlreadyStarted:
                return(SR.Task_Start_AlreadyStarted);

            case ExceptionResource.Task_RunSynchronously_Continuation:
                return(SR.Task_RunSynchronously_Continuation);

            case ExceptionResource.Task_RunSynchronously_Promise:
                return(SR.Task_RunSynchronously_Promise);

            case ExceptionResource.Task_RunSynchronously_TaskCompleted:
                return(SR.Task_RunSynchronously_TaskCompleted);

            case ExceptionResource.Task_RunSynchronously_AlreadyStarted:
                return(SR.Task_RunSynchronously_AlreadyStarted);

            case ExceptionResource.AsyncMethodBuilder_InstanceNotInitialized:
                return(SR.AsyncMethodBuilder_InstanceNotInitialized);

            case ExceptionResource.Task_ContinueWith_ESandLR:
                return(SR.Task_ContinueWith_ESandLR);

            case ExceptionResource.Task_ContinueWith_NotOnAnything:
                return(SR.Task_ContinueWith_NotOnAnything);

            case ExceptionResource.Task_InvalidTimerTimeSpan:
                return(SR.Task_InvalidTimerTimeSpan);

            case ExceptionResource.Task_Delay_InvalidMillisecondsDelay:
                return(SR.Task_Delay_InvalidMillisecondsDelay);

            case ExceptionResource.Task_Dispose_NotCompleted:
                return(SR.Task_Dispose_NotCompleted);

            case ExceptionResource.Task_ThrowIfDisposed:
                return(SR.Task_ThrowIfDisposed);

            case ExceptionResource.Task_WaitMulti_NullTask:
                return(SR.Task_WaitMulti_NullTask);

            case ExceptionResource.ArgumentException_OtherNotArrayOfCorrectLength:
                return(SR.ArgumentException_OtherNotArrayOfCorrectLength);

            case ExceptionResource.ArgumentNull_Array:
                return(SR.ArgumentNull_Array);

            case ExceptionResource.ArgumentNull_SafeHandle:
                return(SR.ArgumentNull_SafeHandle);

            case ExceptionResource.ArgumentOutOfRange_EndIndexStartIndex:
                return(SR.ArgumentOutOfRange_EndIndexStartIndex);

            case ExceptionResource.ArgumentOutOfRange_Enum:
                return(SR.ArgumentOutOfRange_Enum);

            case ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported:
                return(SR.ArgumentOutOfRange_HugeArrayNotSupported);

            case ExceptionResource.Argument_AddingDuplicate:
                return(SR.Argument_AddingDuplicate);

            case ExceptionResource.Argument_InvalidArgumentForComparison:
                return(SR.Argument_InvalidArgumentForComparison);

            case ExceptionResource.Arg_LowerBoundsMustMatch:
                return(SR.Arg_LowerBoundsMustMatch);

            case ExceptionResource.Arg_MustBeType:
                return(SR.Arg_MustBeType);

            case ExceptionResource.Arg_Need1DArray:
                return(SR.Arg_Need1DArray);

            case ExceptionResource.Arg_Need2DArray:
                return(SR.Arg_Need2DArray);

            case ExceptionResource.Arg_Need3DArray:
                return(SR.Arg_Need3DArray);

            case ExceptionResource.Arg_NeedAtLeast1Rank:
                return(SR.Arg_NeedAtLeast1Rank);

            case ExceptionResource.Arg_RankIndices:
                return(SR.Arg_RankIndices);

            case ExceptionResource.Arg_RanksAndBounds:
                return(SR.Arg_RanksAndBounds);

            case ExceptionResource.InvalidOperation_IComparerFailed:
                return(SR.InvalidOperation_IComparerFailed);

            case ExceptionResource.NotSupported_FixedSizeCollection:
                return(SR.NotSupported_FixedSizeCollection);

            case ExceptionResource.Rank_MultiDimNotSupported:
                return(SR.Rank_MultiDimNotSupported);

            case ExceptionResource.Arg_TypeNotSupported:
                return(SR.Arg_TypeNotSupported);

            case ExceptionResource.Argument_SpansMustHaveSameLength:
                return(SR.Argument_SpansMustHaveSameLength);

            case ExceptionResource.Argument_InvalidFlag:
                return(SR.Argument_InvalidFlag);

            case ExceptionResource.CancellationTokenSource_Disposed:
                return(SR.CancellationTokenSource_Disposed);

            default:
                Debug.Fail("The enum value is not defined, please check the ExceptionResource Enum.");
                return("");
            }
        }
 internal static void ThrowArgumentException(ExceptionResource resource) {
     throw new ArgumentException(SR.GetString(GetResourceName(resource)));
 }
Esempio n. 26
0
 internal static void ThrowInvalidOperationException(ExceptionResource resource)
 {
     throw new InvalidOperationException(Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 27
0
 /// <summary>
 /// </summary>
 /// <param name="argument">
 /// The argument.
 /// </param>
 /// <param name="resource">
 /// The resource.
 /// </param>
 /// <exception cref="Exception">
 /// </exception>
 public static void ThorwArgumentCurrentSize(ExceptionArgument argument, ExceptionResource resource)
 {
     throw new Exception(argument + " : " + resource);
 }
Esempio n. 28
0
 internal static void ThrowSerializationException(ExceptionResource resource)
 {
     throw new SerializationException(Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 29
0
 internal static void ThrowInvalidOperationException(
   ExceptionResource resource) {
   throw new InvalidOperationException(GetResourceByName(resource));
 }
Esempio n. 30
0
 internal static void  ThrowSecurityException(ExceptionResource resource)
 {
     throw new System.Security.SecurityException(Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 31
0
 public static InvalidOperationException GetInvalidOperationException(ExceptionResource resource)
 {
     return new InvalidOperationException(GetResourceString(resource));
 }
Esempio n. 32
0
 internal static void ThrowNotSupportedException(ExceptionResource resource)
 {
     throw new NotSupportedException(Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 33
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public LdapException()
     :base()
 {
     m_expRes = new ExceptionResource("Unknown", "Workshare.DirectorySearcher.Exceptions", typeof(LdapException).Assembly);
 }
Esempio n. 34
0
 internal static void ThrowUnauthorizedAccessException(ExceptionResource resource)
 {
     throw new UnauthorizedAccessException(Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 35
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public LdapException(ExceptionResource resource)
     : base()
 {
     if (resource != null)
         m_expRes = resource;
 }
Esempio n. 36
0
 internal static void ThrowObjectDisposedException(string objectName, ExceptionResource resource)
 {
     throw new ObjectDisposedException(objectName, Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 37
0
        //
        // This function will convert an ExceptionResource enum value to the resource string.
        //
        internal static string GetResourceName(ExceptionResource resource)
        {
            string resourceName = null;

            switch (resource)
            {
            case ExceptionResource.Argument_ImplementIComparable:
                resourceName = "Argument_ImplementIComparable";
                break;

            case ExceptionResource.Argument_AddingDuplicate:
                resourceName = "Argument_AddingDuplicate";
                break;

            case ExceptionResource.ArgumentOutOfRange_BiggerThanCollection:
                resourceName = "ArgumentOutOfRange_BiggerThanCollection";
                break;

            case ExceptionResource.ArgumentOutOfRange_Count:
                resourceName = "ArgumentOutOfRange_Count";
                break;

            case ExceptionResource.ArgumentOutOfRange_Index:
                resourceName = "ArgumentOutOfRange_Index";
                break;

            case ExceptionResource.ArgumentOutOfRange_InvalidThreshold:
                resourceName = "ArgumentOutOfRange_InvalidThreshold";
                break;

            case ExceptionResource.ArgumentOutOfRange_ListInsert:
                resourceName = "ArgumentOutOfRange_ListInsert";
                break;

            case ExceptionResource.ArgumentOutOfRange_NeedNonNegNum:
                resourceName = "ArgumentOutOfRange_NeedNonNegNum";
                break;

            case ExceptionResource.ArgumentOutOfRange_SmallCapacity:
                resourceName = "ArgumentOutOfRange_SmallCapacity";
                break;

            case ExceptionResource.Arg_ArrayPlusOffTooSmall:
                resourceName = "Arg_ArrayPlusOffTooSmall";
                break;

            case ExceptionResource.Arg_RankMultiDimNotSupported:
                resourceName = "Arg_RankMultiDimNotSupported";
                break;

            case ExceptionResource.Arg_NonZeroLowerBound:
                resourceName = "Arg_NonZeroLowerBound";
                break;

            case ExceptionResource.Argument_InvalidArrayType:
                resourceName = "Argument_InvalidArrayType";
                break;

            case ExceptionResource.Argument_InvalidOffLen:
                resourceName = "Argument_InvalidOffLen";
                break;

            case ExceptionResource.Argument_ItemNotExist:
                resourceName = "Argument_ItemNotExist";
                break;

            case ExceptionResource.InvalidOperation_CannotRemoveFromStackOrQueue:
                resourceName = "InvalidOperation_CannotRemoveFromStackOrQueue";
                break;

            case ExceptionResource.InvalidOperation_EmptyQueue:
                resourceName = "InvalidOperation_EmptyQueue";
                break;

            case ExceptionResource.InvalidOperation_EnumOpCantHappen:
                resourceName = "InvalidOperation_EnumOpCantHappen";
                break;

            case ExceptionResource.InvalidOperation_EnumFailedVersion:
                resourceName = "InvalidOperation_EnumFailedVersion";
                break;

            case ExceptionResource.InvalidOperation_EmptyStack:
                resourceName = "InvalidOperation_EmptyStack";
                break;

            case ExceptionResource.InvalidOperation_EnumNotStarted:
                resourceName = "InvalidOperation_EnumNotStarted";
                break;

            case ExceptionResource.InvalidOperation_EnumEnded:
                resourceName = "InvalidOperation_EnumEnded";
                break;

            case ExceptionResource.NotSupported_KeyCollectionSet:
                resourceName = "NotSupported_KeyCollectionSet";
                break;

            case ExceptionResource.NotSupported_ReadOnlyCollection:
                resourceName = "NotSupported_ReadOnlyCollection";
                break;

            case ExceptionResource.NotSupported_ValueCollectionSet:
                resourceName = "NotSupported_ValueCollectionSet";
                break;


            case ExceptionResource.NotSupported_SortedListNestedWrite:
                resourceName = "NotSupported_SortedListNestedWrite";
                break;


            case ExceptionResource.Serialization_InvalidOnDeser:
                resourceName = "Serialization_InvalidOnDeser";
                break;

            case ExceptionResource.Serialization_MissingKeys:
                resourceName = "Serialization_MissingKeys";
                break;

            case ExceptionResource.Serialization_NullKey:
                resourceName = "Serialization_NullKey";
                break;

            case ExceptionResource.Argument_InvalidType:
                resourceName = "Argument_InvalidType";
                break;

            case ExceptionResource.Argument_InvalidArgumentForComparison:
                resourceName = "Argument_InvalidArgumentForComparison";
                break;

            case ExceptionResource.InvalidOperation_NoValue:
                resourceName = "InvalidOperation_NoValue";
                break;

            case ExceptionResource.InvalidOperation_RegRemoveSubKey:
                resourceName = "InvalidOperation_RegRemoveSubKey";
                break;

            case ExceptionResource.Arg_RegSubKeyAbsent:
                resourceName = "Arg_RegSubKeyAbsent";
                break;

            case ExceptionResource.Arg_RegSubKeyValueAbsent:
                resourceName = "Arg_RegSubKeyValueAbsent";
                break;

            case ExceptionResource.Arg_RegKeyDelHive:
                resourceName = "Arg_RegKeyDelHive";
                break;

            case ExceptionResource.Security_RegistryPermission:
                resourceName = "Security_RegistryPermission";
                break;

            case ExceptionResource.Arg_RegSetStrArrNull:
                resourceName = "Arg_RegSetStrArrNull";
                break;

            case ExceptionResource.Arg_RegSetMismatchedKind:
                resourceName = "Arg_RegSetMismatchedKind";
                break;

            case ExceptionResource.UnauthorizedAccess_RegistryNoWrite:
                resourceName = "UnauthorizedAccess_RegistryNoWrite";
                break;

            case ExceptionResource.ObjectDisposed_RegKeyClosed:
                resourceName = "ObjectDisposed_RegKeyClosed";
                break;

            case ExceptionResource.Arg_RegKeyStrLenBug:
                resourceName = "Arg_RegKeyStrLenBug";
                break;

            case ExceptionResource.Argument_InvalidRegistryKeyPermissionCheck:
                resourceName = "Argument_InvalidRegistryKeyPermissionCheck";
                break;

            case ExceptionResource.NotSupported_InComparableType:
                resourceName = "NotSupported_InComparableType";
                break;

            case ExceptionResource.Argument_InvalidRegistryOptionsCheck:
                resourceName = "Argument_InvalidRegistryOptionsCheck";
                break;

            case ExceptionResource.Argument_InvalidRegistryViewCheck:
                resourceName = "Argument_InvalidRegistryViewCheck";
                break;

            default:
                Contract.Assert(false, "The enum value is not defined, please checked ExceptionArgumentName Enum.");
                return(string.Empty);
            }

            return(resourceName);
        }
Esempio n. 38
0
 internal static void ThrowArgumentException(ExceptionResource resource, ExceptionArgument argument)
 {
     throw new ArgumentException(Environment.GetResourceString(GetResourceName(resource)), GetArgumentName(argument));
 }
Esempio n. 39
0
 internal static void ThrowArgumentOutOfRangeException(ExceptionResource resource,int value)
 {
     throw new ArgumentOutOfRangeException("value",value,GetResource(resource));
 }
Esempio n. 40
0
 internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
 {
     if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
     {
         // Dev11 474369 quirk: Mango had an empty message string:
         throw new ArgumentOutOfRangeException(GetArgumentName(argument), String.Empty);
     }
     else
     {
         throw new ArgumentOutOfRangeException(GetArgumentName(argument),
                                               Environment.GetResourceString(GetResourceName(resource)));
     }
 }
Esempio n. 41
0
        /// <summary>
        /// Used to work out which Ldap Engine does the entry belong to.
        /// </summary>
        /// <param name="entry">The entry the Ldap Engine can be detected from</param>
        /// <returns>The type of engine it belongs to.</returns>
        public void WorkoutEngineType(DirectoryEntry entry)
        {
            m_type = EngineType.Unknown;
            StringBuilder sb = new StringBuilder();
            try
            {
                if (entry.Properties.Contains("vendorname"))
                {
                    string vendor = entry.Properties["vendorname"][0].ToString().ToLower(System.Threading.Thread.CurrentThread.CurrentCulture);
                    if (vendor.IndexOf("lotus") > -1)
                        LdapType = EngineType.Domino;
                    if (vendor.IndexOf("novell") > -1)
                        LdapType = EngineType.Novell;
                }

                if (LdapType == EngineType.Unknown)
                {
                    if (entry.Properties.Contains("rootDomainNamingContext") ||
                        entry.Properties.Contains("nTMixedDomain"))
                        LdapType = EngineType.ActiveDirectory;
                }
                sb.AppendFormat(ResourceManager.GetString("LDAP_DETECT",
                            "Workshare.DirectorySearcher.Exceptions", typeof(LdapServerInformation).Assembly), LdapType);
                Logger.LogInfo(sb.ToString());
            }
            catch (COMException e)
            {
                ExceptionResource er = new ExceptionResource("LDAPACCESS", "Workshare.DirectorySearcher.Exceptions", typeof(LdapServerInformation).Assembly);
                sb.AppendFormat(er.Description, Environment.NewLine, e.Message, entry.Path);
                er.Description = sb.ToString();
				Logger.LogInfo(sb.ToString());
                throw (new InvalidOperationException(sb.ToString(), e));
            }
        }
Esempio n. 42
0
 internal static void ThrowArgumentException(ExceptionResource resource)
 {
     throw GetArgumentException(resource);
 }
Esempio n. 43
0
 internal static void ThrowArgumentException(ExceptionResource resource, ExceptionArgument argument)
 {
     throw new ArgumentException(Environment.GetResourceString(GetResourceName(resource)), GetArgumentName(argument));
 }
Esempio n. 44
0
 internal static void ThrowArgumentException(ExceptionResource resource, ExceptionArgument argument)
 {
     throw GetArgumentException(resource, argument);
 }
Esempio n. 45
0
 internal static void ThrowObjectDisposedException(string objectName, ExceptionResource resource)
 {
     throw new ObjectDisposedException(objectName, Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 46
0
 internal static void ThrowArgumentNullException(ExceptionArgument argument, ExceptionResource resource)
 {
     throw new ArgumentNullException(GetArgumentName(argument), GetResourceString(resource));
 }
Esempio n. 47
0
 internal static void ThrowUnauthorizedAccessException(ExceptionResource resource)
 {
     throw new UnauthorizedAccessException(Environment.GetResourceString(GetResourceName(resource)));
 }
Esempio n. 48
0
 internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, int paramNumber, ExceptionResource resource)
 {
     throw GetArgumentOutOfRangeException(argument, paramNumber, resource);
 }
        //
        // This function will convert an ExceptionResource enum value to the resource string.
        //
        internal static string GetResourceName(ExceptionResource resource) {
            string resourceName = null;

            switch (resource) {
                case ExceptionResource.Argument_ImplementIComparable:
                    resourceName = SR.Argument_ImplementIComparable;
                    break;

                case ExceptionResource.Argument_AddingDuplicate:
                    resourceName = SR.Argument_AddingDuplicate;
                    break;

                case ExceptionResource.ArgumentOutOfRange_Index:
                    resourceName = SR.ArgumentOutOfRange_Index;
                    break;

                case ExceptionResource.ArgumentOutOfRange_NeedNonNegNum:
                    resourceName = SR.ArgumentOutOfRange_NeedNonNegNum;
                    break;

                case ExceptionResource.ArgumentOutOfRange_NeedNonNegNumRequired:
                    resourceName = SR.ArgumentOutOfRange_NeedNonNegNumRequired;
                    break;

                case ExceptionResource.ArgumentOutOfRange_SmallCapacity:
                    resourceName = SR.ArgumentOutOfRange_SmallCapacity;
                    break;

                case ExceptionResource.Arg_ArrayPlusOffTooSmall:
                    resourceName = SR.Arg_ArrayPlusOffTooSmall;
                    break;

                case ExceptionResource.Arg_RankMultiDimNotSupported:
                    resourceName = SR.Arg_MultiRank;
                    break;

                case ExceptionResource.Arg_NonZeroLowerBound:
                    resourceName = SR.Arg_NonZeroLowerBound;
                    break;

                case ExceptionResource.Argument_InvalidArrayType:
                    resourceName = SR.Invalid_Array_Type;
                    break;

                case ExceptionResource.Argument_InvalidOffLen:
                    resourceName = SR.Argument_InvalidOffLen;
                    break;

                case ExceptionResource.InvalidOperation_CannotRemoveFromStackOrQueue:
                    resourceName = SR.InvalidOperation_CannotRemoveFromStackOrQueue;
                    break;

                case ExceptionResource.InvalidOperation_EmptyCollection:
                    resourceName = SR.InvalidOperation_EmptyCollection;
                    break;

                case ExceptionResource.InvalidOperation_EmptyQueue:
                    resourceName = SR.InvalidOperation_EmptyQueue;
                    break;

                case ExceptionResource.InvalidOperation_EnumOpCantHappen:
                    resourceName = SR.InvalidOperation_EnumOpCantHappen;
                    break;

                case ExceptionResource.InvalidOperation_EnumFailedVersion:
                    resourceName = SR.InvalidOperation_EnumFailedVersion;
                    break;

                case ExceptionResource.InvalidOperation_EmptyStack:
                    resourceName = SR.InvalidOperation_EmptyStack;
                    break;

                case ExceptionResource.InvalidOperation_EnumNotStarted:
                    resourceName = SR.InvalidOperation_EnumNotStarted;
                    break;

                case ExceptionResource.InvalidOperation_EnumEnded:
                    resourceName = SR.InvalidOperation_EnumEnded;
                    break;

                case ExceptionResource.NotSupported_KeyCollectionSet:
                    resourceName = SR.NotSupported_KeyCollectionSet;
                    break;

                case ExceptionResource.NotSupported_SortedListNestedWrite:
                    resourceName = SR.NotSupported_SortedListNestedWrite;
                    break;


                case ExceptionResource.Serialization_InvalidOnDeser:
                    resourceName = SR.Serialization_InvalidOnDeser;
                    break;

                case ExceptionResource.Serialization_MissingValues:
                    resourceName = SR.Serialization_MissingValues;
                    break;

                case ExceptionResource.Serialization_MismatchedCount:
                    resourceName = SR.Serialization_MismatchedCount;
                    break;

                case ExceptionResource.NotSupported_ValueCollectionSet:
                    resourceName = SR.NotSupported_ValueCollectionSet;
                    break;

                default:
                    Debug.Assert(false, "The enum value is not defined, please checked ExceptionArgumentName Enum.");
                    return string.Empty;
            }

            return resourceName;
        }
Esempio n. 50
0
 internal static void ThrowInvalidOperationException(ExceptionResource resource)
 {
     throw GetInvalidOperationException(resource);
 }
 internal static void ThrowInvalidOperationException(ExceptionResource resource) {
     throw new InvalidOperationException(SR.GetString(GetResourceName(resource)));
 }
Esempio n. 52
0
 internal static void ThrowInvalidOperationException(ExceptionResource resource, Exception e)
 {
     throw new InvalidOperationException(GetResourceString(resource), e);
 }
 internal static void ThrowNotSupportedException(ExceptionResource resource) {
     throw new NotSupportedException(SR.GetString(GetResourceName(resource)));
 }
Esempio n. 54
0
 internal static void ThrowSerializationException(ExceptionResource resource)
 {
     throw new SerializationException(GetResourceString(resource));
 }
Esempio n. 55
0
 /// <summary>
 /// </summary>
 /// <param name="argument">
 /// The argument.
 /// </param>
 /// <param name="resource">
 /// The resource.
 /// </param>
 /// <exception cref="ArgumentOutOfRangeException">
 /// </exception>
 public static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
 {
     throw new ArgumentOutOfRangeException(argument.ToString(), resource.ToString());
 }
Esempio n. 56
0
 internal static void ThrowSecurityException(ExceptionResource resource)
 {
     throw new System.Security.SecurityException(GetResourceString(resource));
 }
Esempio n. 57
0
 internal static void ThrowArgumentException(ExceptionResource resource) {
   throw new ArgumentException(GetResourceByName(resource));
 }
Esempio n. 58
0
 public static void ThrowInvalidOperationException(ExceptionResource resource)
 {
     throw GetInvalidOperationException(resource);
 }
Esempio n. 59
0
 internal static void ThrowArgumentOutOfRangeException(
   ExceptionArgument argument, ExceptionResource resource) {
   throw new ArgumentOutOfRangeException(GetArgumentName(argument),
     GetResourceByName(resource));
 }
Esempio n. 60
0
 internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
 {
     throw new ArgumentOutOfRangeException(GetArgumentName(argument),
                                           Environment.GetResourceString(GetResourceName(resource)));
 }