Example #1
0
        public static Atom FromExisting([NotNull] String name)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var atomId = LocalAtomNativeMethods.FindAtom(name);

            if (atomId == 0)
            {
                throw new Win32Exception();
            }

            return(new LocalAtom(atomId, name));
        }
Example #2
0
        public static Atom CreateNew(String name)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var existingLocalAtom = LocalAtomNativeMethods.FindAtom(name);

            if (existingLocalAtom == 0)
            {
                existingLocalAtom = LocalAtomNativeMethods.AddAtom(name);
                if (existingLocalAtom == 0)
                {
                    throw new Win32Exception();
                }

                return(new LocalAtom(existingLocalAtom, name));
            }

            throw new Win32Exception();
        }