本文整理汇总了C#中Work类的典型用法代码示例。如果您正苦于以下问题:C# Work类的具体用法?C# Work怎么用?C# Work使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Work类属于命名空间,在下文中一共展示了Work类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetXmlForWork
/// ------------------------------------------------------------------------------------
public string GetXmlForWork(Work work)
{
var bldr = new StringBuilder();
if (work != null)
{
bldr.Append(GetOlacRecordElement());
foreach (var contributor in work.Contributions)
bldr.Append(GetContributorElement(contributor.Role.Code, contributor.ContributorName));
bldr.Append("</olac:olac>");
}
return bldr.ToString();
/* <dc:language xsi:type="olac:language" olac:code="adz"
view="Adzera"/>
<dc:subject xsi:type="olac:language" olac:code="adz"
view="Adzera"/>
<dc:title>Language</dc:title>
<dc:publisher>New York: Holt</dc:publisher>
*/
}
示例2: ContentHub
public ContentHub(Work<IContentManager> workContentManager,
Work<IAuthenticationService> workAuthenticationService,
IClock clock) {
_workContentManager = workContentManager;
_workAuthenticationService = workAuthenticationService;
_clock = clock;
}
示例3: Search
/// <summary>
/// Implements the search function in managed code.
/// </summary>
/// <param name="work"></param>
/// <param name="round1State"></param>
/// <param name="round1Block2"></param>
/// <param name="round2State"></param>
/// <param name="round2Block1"></param>
/// <returns></returns>
public unsafe override uint? Search(Work work, uint* round1State, byte* round1Block2, uint* round2State, byte* round2Block1)
{
// starting nonce
uint nonce = 0;
// output for final hash
uint* round2State2 = stackalloc uint[Sha256.SHA256_STATE_SIZE];
while (true)
{
// update the nonce value
((uint*)round1Block2)[3] = nonce;
// transform variable second half of block using saved state from first block, into pre-padded round 2 block (end of first hash)
Sha256.Transform(round1State, round1Block2, (uint*)round2Block1);
// transform round 2 block into round 2 state (second hash)
Sha256.Transform(round2State, round2Block1, round2State2);
// test for potentially valid hash
if (round2State2[7] == 0U)
// actual nonce is flipped
return Memory.ReverseEndian(nonce);
// only report and check for exit conditions every so often
if ((++nonce % 65536) == 0)
if (!Progress(work, 65536) || nonce == 0)
break;
}
return null;
}
示例4: ShoutboxHub
public ShoutboxHub(Work<IOrchardServices> orchardServices, IHelpers helpers, IShoutboxService shoutboxService, IPostService postService)
{
if (orchardServices == null)
{
throw new ArgumentNullException("orchardServices");
}
if (helpers == null)
{
throw new ArgumentNullException("helpers");
}
if (postService == null)
{
throw new ArgumentNullException("postService");
}
if (shoutboxService == null)
{
throw new ArgumentNullException("shoutboxService");
}
_OrchardServices = orchardServices;
_Helpers = helpers;
_ShoutboxService = shoutboxService;
_PostService = postService;
}
示例5: Shapes
public Shapes(
Work<WorkContext> workContext,
Work<INavigationManager> navigationManager)
{
_workContext = workContext;
_navigationManager = navigationManager;
}
示例6: FacebookConnectWidgetPartHandler
public FacebookConnectWidgetPartHandler(Work<ISiteService> siteServiceWork)
{
OnActivated<FacebookConnectWidgetPart>((context, part) =>
{
part.PermissionsField.Loader(() => siteServiceWork.Value.GetSiteSettings().As<FacebookConnectSettingsPart>().Permissions);
});
}
示例7: Main
static void Main(string[] args)
{
int N = int.Parse(Console.ReadLine());
var works = new Work[N];
for (int i = 0; i < N; i++)
{
string[] inputs = Console.ReadLine().Split(' ');
int J = int.Parse(inputs[0]);
int D = int.Parse(inputs[1]);
works[i] = new Work { Starts = J, Ends = J + D - 1 };
}
var sortedWorks = works.OrderBy(x => x.Ends).ThenBy(x => x.Starts).ToArray();
var lastEnd = 0;
var count = 0;
for (int i = 0; i < sortedWorks.Length; i++)
{
if (sortedWorks[i].Starts > lastEnd)
{
count++;
lastEnd = sortedWorks[i].Ends;
}
}
Console.WriteLine(count);
}
示例8: DefaultExceptionPolicy
public DefaultExceptionPolicy(INotifier notifier, Work<IAuthorizer> authorizer)
{
_notifier = notifier;
_authorizer = authorizer;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
}
示例9: ScriptDifferences
private ExecutionBlock ScriptDifferences(Differences differences)
{
var work = new Work();
work.BuildFromDifferences(differences, Options.Default, true);
ExecutionBlock block = work.ExecutionBlock;
return block;
}
示例10: Main
static void Main()
{
// Create the thread object. This does not start the thread.
Worker workerObject = new Work();
Thread workerThread = new Thread(workerObject.DoWork);
// Start the worker thread.
workerThread.Start();
Console.WriteLine("main thread: Starting worker thread...");
// Loop until worker thread activates.
while (!workerThread.IsAlive) ;
// Put the main thread to sleep for 1 millisecond to
// allow the worker thread to do some work:
Thread.Sleep(1);
// Request that the worker thread stop itself:
workerObject.RequestStop();
// Use the Join method to block the current thread
// until the object's thread terminates.
workerThread.Join();
Console.WriteLine("main thread: Worker thread has terminated.");
}
示例11: Main
public static void Main()
{
try
{
TTransport transport = new TSocket("localhost", 9090);
TProtocol protocol = new TBinaryProtocol(transport);
Calculator.Client client = new Calculator.Client(protocol);
transport.Open();
try
{
client.ping();
Console.WriteLine("ping()");
int sum = client.add(1, 1);
Console.WriteLine("1+1={0}", sum);
Work work = new Work();
work.Op = Operation.DIVIDE;
work.Num1 = 1;
work.Num2 = 0;
try
{
int quotient = client.calculate(1, work);
Console.WriteLine("Whoa we can divide by 0");
}
catch (InvalidOperation io)
{
Console.WriteLine("Invalid operation: " + io.Why);
}
work.Op = Operation.SUBTRACT;
work.Num1 = 15;
work.Num2 = 10;
try
{
int diff = client.calculate(1, work);
Console.WriteLine("15-10={0}", diff);
}
catch (InvalidOperation io)
{
Console.WriteLine("Invalid operation: " + io.Why);
}
SharedStruct log = client.getStruct(1);
Console.WriteLine("Check log: {0}", log.Value);
}
finally
{
transport.Close();
}
}
catch (TApplicationException x)
{
Console.WriteLine(x.StackTrace);
}
}
示例12: PerformWork
public void PerformWork(Work work, ISessionImplementor session)
{
if (session.TransactionInProgress)
{
ITransaction transaction = ((ISession)session).Transaction;
PostTransactionWorkQueueSynchronization txSync = (PostTransactionWorkQueueSynchronization)
synchronizationPerTransaction[transaction];
if (txSync == null || txSync.IsConsumed)
{
txSync =
new PostTransactionWorkQueueSynchronization(queueingProcessor, synchronizationPerTransaction);
transaction.RegisterSynchronization(txSync);
lock (synchronizationPerTransaction.SyncRoot)
synchronizationPerTransaction[transaction] = txSync;
}
txSync.Add(work);
}
else
{
WorkQueue queue = new WorkQueue(2); //one work can be split
queueingProcessor.Add(work, queue);
queueingProcessor.PrepareWorks(queue);
queueingProcessor.PerformWorks(queue);
}
}
示例13: FileRecordSequenceCompletedAsyncResult
public FileRecordSequenceCompletedAsyncResult(
SequenceNumber result,
AsyncCallback callback,
object userState,
Work work)
{
this.result = result;
this.callback = callback;
this.userState = userState;
this.work = work;
this.syncRoot = new object();
if (this.callback != null)
{
try
{
this.callback(this);
}
#pragma warning suppress 56500 // This is a callback exception
catch (Exception e)
{
if (Fx.IsFatal(e))
throw;
throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
}
}
}
示例14: Main
static void Main()
{
// To start a thread using a static thread procedure, use the
// class name and method name when you create the ThreadStart
// delegate. Beginning in version 2.0 of the .NET Framework,
// it is not necessary to create a delegate explicitly.
// Specify the name of the method in the Thread constructor,
// and the compiler selects the correct delegate. For example:
//
Thread newThread = new Thread(Work.DoWork);
//
// ThreadStart threadDelegate = new ThreadStart(Work.DoWork);
// Thread newThread = new Thread(threadDelegate);
newThread.Start();
// To start a thread using an instance method for the thread
// procedure, use the instance variable and method name when
// you create the ThreadStart delegate. Beginning in version
// 2.0 of the .NET Framework, the explicit delegate is not
// required.
//
Work w = new Work();
w.Data = 42;
newThread = new Thread(w.DoMoreWork); //directly attach newThread to a new method
// threadDelegate = new ThreadStart(w.DoMoreWork);
// newThread = new Thread(threadDelegate);
newThread.Start();
}
示例15: TypicalEmbedInMyXmlDocument
public void TypicalEmbedInMyXmlDocument()
{
var system = new OlacSystem();
var work = new Work();
work.Licenses.Add(License.CreativeCommons_Attribution_ShareAlike);
work.Contributions.Add(new Contribution("Charlie Brown", system.GetRoleByCodeOrThrow("author")));
work.Contributions.Add(new Contribution("Linus", system.GetRoleByCodeOrThrow("editor")));
string metaData = system.GetXmlForWork(work);
//Embed that data in our own file
using (var f = new TempFile(@"<doc>
<metadata>" + metaData + @"</metadata>
<ourDocumentContents>blah blah<ourDocumentContents/></doc>"))
{
//Then when it comes time to read the file, we can extract out the work again
var dom = new XmlDocument();
dom.Load(f.Path);
var node = dom.SelectSingleNode("//metadata");
var work2 = new Work();
system.LoadWorkFromXml(work2, node.InnerXml);
Assert.AreEqual(2,work2.Contributions.Count());
}
}